@crossworks/client-types 0.239.2 → 0.239.4

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@crossworks/client-types",
3
- "version": "0.239.2",
3
+ "version": "0.239.4",
4
4
  "type": "module",
5
5
  "main": "./src/index.ts",
6
6
  "types": "./src/index.ts",
@@ -0,0 +1,91 @@
1
+ /**
2
+ * Optional services: the box services an admin can switch on and off from
3
+ * the dashboard (sandboxes, media). GET /api/services returns a
4
+ * {@link ServicesView}; POST /api/services/:name {enable} asks the updater
5
+ * sidecar to switch one; GET /api/services/status is the progress poll.
6
+ */
7
+
8
+ export type OptionalServiceName = 'sandboxes' | 'media';
9
+
10
+ /**
11
+ * - `off`: the compose profile is not active (the resting state).
12
+ * - `up`: on and answering its health probe.
13
+ * - `down`: on but not answering (starting, crashed, or misconfigured).
14
+ */
15
+ export type ServiceState = 'off' | 'up' | 'down';
16
+
17
+ /** Plain-language facts the UI shows next to the switch. Brain-authored, so
18
+ * the sizes stay next to the compose file they describe. */
19
+ export type ServiceDescription = {
20
+ title: string;
21
+ /** What it does, one or two sentences. */
22
+ what: string;
23
+ /** Which features use it. */
24
+ usedBy: string;
25
+ /** What stops working while it is off. */
26
+ whenOff: string;
27
+ /** What switching it off keeps (never removed). */
28
+ keeps: string;
29
+ /** Approximate first download, in MB (compressed). */
30
+ downloadMb: number;
31
+ /** Memory, as a short phrase ("up to 1 GB"). */
32
+ memory: string;
33
+ /** Upper bound in MB, for the small-box warning. */
34
+ memoryMaxMb: number;
35
+ /** A security note, when the service carries one. */
36
+ note: string | null;
37
+ };
38
+
39
+ export type ServiceInfo = {
40
+ name: OptionalServiceName;
41
+ state: ServiceState;
42
+ /** The container as docker reports it ('running', 'exited', 'absent'),
43
+ * and its healthcheck ('healthy', 'starting', 'none'). Null when the
44
+ * updater has not reported yet. */
45
+ container: string | null;
46
+ health: string | null;
47
+ description: ServiceDescription;
48
+ };
49
+
50
+ /** One switch run, from the updater's service-status.json. */
51
+ export type ServiceRunPhase =
52
+ 'idle' | 'requested' | 'pulling' | 'starting' | 'stopping' | 'done' | 'error';
53
+
54
+ export type ServiceRunStatus = {
55
+ phase: ServiceRunPhase;
56
+ service: OptionalServiceName | null;
57
+ enable: boolean | null;
58
+ startedAt: string | null;
59
+ finishedAt: string | null;
60
+ ok: boolean | null;
61
+ error: string | null;
62
+ };
63
+
64
+ export type ServicesView = {
65
+ services: ServiceInfo[];
66
+ /** Whether this box can switch services from the UI, and why not. */
67
+ switching: {
68
+ available: boolean;
69
+ /** Null when available. */
70
+ reason: string | null;
71
+ };
72
+ box: {
73
+ memTotalBytes: number | null;
74
+ memAvailableBytes: number | null;
75
+ diskFreeBytes: number | null;
76
+ /** The 4 GB brain-core shape. */
77
+ core: boolean;
78
+ /** A box this small should be warned before a service goes on. */
79
+ smallBox: boolean;
80
+ };
81
+ /** The current or last switch run. */
82
+ run: ServiceRunStatus | null;
83
+ };
84
+
85
+ export type ServiceSwitchResult = { ok: true } | { ok: false; error: string };
86
+
87
+ export type ServiceRunPoll = {
88
+ run: ServiceRunStatus | null;
89
+ /** Tail of the run's output (service.log). */
90
+ log: string;
91
+ };
package/src/index.ts CHANGED
@@ -34,6 +34,7 @@ export * from './dto/rows';
34
34
  export * from './dto/views';
35
35
  export * from './dto/recall';
36
36
  export * from './dto/contact-shares';
37
+ export * from './dto/services';
37
38
  // Types only; ACCESS_LEVELS (runtime) is the `@mantle/client-types/dto/access` subpath.
38
39
  export type {
39
40
  AccessItemView,