@biolibs/bionet-space 0.0.0-stage → 0.2.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/src/model.ts ADDED
@@ -0,0 +1,105 @@
1
+ /**
2
+ * What a lab is made of, as far as finding things goes: places, and what is stored in them.
3
+ *
4
+ * A lab is a tree of places. A room holds a freezer, which holds shelves, which hold racks, which
5
+ * hold boxes. Nothing here says a tree must have those levels: a place has a kind and a parent, and
6
+ * that is all a place has to have. A liquid nitrogen dewar with canes in it is as much a lab as a
7
+ * freezer with racks.
8
+ *
9
+ * **Where a place is in the tree is required. Where it stands in the room is not.** A lab can say
10
+ * "this tube is in box 3, rack B, the −80" without anybody drawing a floor plan, and `arrange` will
11
+ * give every place somewhere sensible to stand. A place that does say where it stands is put there.
12
+ *
13
+ * Everything is plain data, so it can be made from signed entries, sent to another process, or
14
+ * written by hand.
15
+ */
16
+
17
+ /**
18
+ * The kinds of place this package knows how to arrange. Any other string is allowed and is treated
19
+ * as a plain container.
20
+ */
21
+ export type PlaceKind = "room" | "freezer" | "fridge" | "bench" | "instrument" | "shelf" | "rack" | "box";
22
+
23
+ /** A quarter turn clockwise, seen from above. */
24
+ export type Turn = 0 | 90 | 180 | 270;
25
+
26
+ /** Where a place stands and how big it is, in metres. */
27
+ export interface Standing {
28
+ /**
29
+ * The centre of its base, measured from the centre of its parent's base: across (x), up (y) and
30
+ * towards the front (z). A room has no parent and is measured from the lab's origin.
31
+ */
32
+ position: [number, number, number];
33
+ /** How wide (x), tall (y) and deep (z) it is, before it is turned. */
34
+ size: [number, number, number];
35
+ /** How far it is turned. Its front faces +z when it is not turned at all. */
36
+ turn?: Turn;
37
+ }
38
+
39
+ /** One place. */
40
+ export interface Place {
41
+ /** Its ID, which never changes. */
42
+ id: string;
43
+ /** What kind of place it is. One of `PlaceKind`, or anything else. */
44
+ kind: string;
45
+ /** What the lab calls it. */
46
+ name: string;
47
+ /** The place it is in, or `null` for a room. */
48
+ parent: string | null;
49
+ /** Where it stands, if anybody has said. Otherwise `arrange` decides. */
50
+ standing?: Standing;
51
+ /** For a box: how many rows and columns of positions it has. */
52
+ grid?: { rows: number; columns: number };
53
+ /** For an instrument: which one, like `thermocycler`. */
54
+ model?: string;
55
+ }
56
+
57
+ /** One position in a box. Rows and columns count from 0, from the back left. */
58
+ export interface Slot {
59
+ row: number;
60
+ column: number;
61
+ }
62
+
63
+ /** One physical item, and where it is. */
64
+ export interface Stored {
65
+ /** The item's ID. */
66
+ item: string;
67
+ /** The place it is in. */
68
+ place: string;
69
+ /** Its position there, if the place has positions and somebody said which. */
70
+ slot?: Slot | null;
71
+ /** The checksum of the part it is an item of. */
72
+ part: string;
73
+ /** What the part is called. */
74
+ name: string;
75
+ /** How much there is. */
76
+ amount: number;
77
+ /** What one of that is. */
78
+ unit: string | null;
79
+ /** Whether the log has lost track of it and it needs counting. */
80
+ needsRecount?: boolean;
81
+ }
82
+
83
+ /** A lab, as far as finding things goes. */
84
+ export interface Layout {
85
+ /** Every place. */
86
+ places: Place[];
87
+ /** Everything stored, and where. */
88
+ stored: Stored[];
89
+ }
90
+
91
+ /** A place with somewhere to stand worked out, in the lab's own coordinates. */
92
+ export interface Arranged {
93
+ /** The place. */
94
+ place: Place;
95
+ /** The centre of the space it takes up, in metres from the lab's origin. */
96
+ center: [number, number, number];
97
+ /** How wide (x), tall (y) and deep (z) that space is, after any turning. */
98
+ size: [number, number, number];
99
+ /** How far it is turned in all, counting everything it is inside. */
100
+ turn: Turn;
101
+ /** Every place it is inside, outermost first, ending with itself. */
102
+ path: string[];
103
+ /** Whether anybody said where it stands, or `arrange` chose. */
104
+ placed: "by hand" | "by default";
105
+ }