@tsplc/debug 0.2.16 → 0.2.18

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/api.ts CHANGED
@@ -1,4 +1,5 @@
1
- import type { TelemetryRecord } from "@tsplc/server/telemetry";
1
+ import type { ServiceCall } from "@tsplc/server";
2
+ import type { AppRecord } from "@tsplc/server/telemetry";
2
3
  import type { DebugManifest, SourceRange } from "./manifest.ts";
3
4
 
4
5
  /**
@@ -11,61 +12,62 @@ export type Quality = "good" | "uncertain" | "bad" | "unavailable";
11
12
 
12
13
  /** One value as read. Values of different paths may come from different scans. */
13
14
  export interface Sample {
14
- path: string;
15
- value: unknown;
16
- quality: Quality;
17
- status: string;
18
- /** When the debugger host received it; the controller reports no time of its own. */
19
- receivedAt: string;
15
+ path: string;
16
+ value: unknown;
17
+ quality: Quality;
18
+ status: string;
19
+ /** When the debugger host received it; the controller reports no time of its own. */
20
+ receivedAt: string;
20
21
  }
21
22
 
22
23
  /** `unavailable`: nothing to read through, such as no engineering login open. */
23
- export type ConnectionState = "connecting" | "connected" | "lost" | "failed" | "unavailable";
24
+ export type ConnectionState =
25
+ "connecting" | "connected" | "lost" | "failed" | "unavailable";
24
26
 
25
27
  export interface Session {
26
- build: { manifest: string | null; controller: string | null; matches: boolean };
27
- connection: { state: ConnectionState; since: string; endpoint: string; error?: string };
28
- /** How live values are read, such as "engineering login", and how often. */
29
- reading: { method: string; intervalMs: number };
30
- /** From the tasks' telemetry batches; `dropped` counts records overwritten before they were sent. */
31
- tasks: { name: string; scan: number | null; scansPerSecond: number | null; dropped: number }[];
32
- /** PLC clock minus the app server's clock, estimated from telemetry batches. */
33
- clock: { offsetMs: number; uncertaintyMs: number } | null;
34
- release?: { id: string; deployedAt: string; operation: string };
35
- /** The project directory on the host, when served by `tsplc debug`. */
36
- projectRoot?: string;
28
+ build: {
29
+ manifest: string | null;
30
+ controller: string | null;
31
+ matches: boolean;
32
+ };
33
+ connection: {
34
+ state: ConnectionState;
35
+ since: string;
36
+ endpoint: string;
37
+ error?: string;
38
+ };
39
+ /** How live values are read, such as "engineering login", and how often. */
40
+ reading: { method: string; intervalMs: number };
41
+ /** From the tasks' telemetry batches; `dropped` counts records overwritten before they were sent. */
42
+ tasks: {
43
+ name: string;
44
+ scan: number | null;
45
+ scansPerSecond: number | null;
46
+ dropped: number;
47
+ }[];
48
+ /** PLC clock minus the app server's clock, estimated from telemetry batches. */
49
+ clock: { offsetMs: number; uncertaintyMs: number } | null;
50
+ release?: { id: string; deployedAt: string; operation: string };
51
+ /** The project directory on the host, when served by `tsplc debug`. */
52
+ projectRoot?: string;
37
53
  }
38
54
 
39
55
  /** A trace record, decoded through the manifest's event sites. */
40
56
  export interface TraceEvent {
41
- sequence: number;
42
- task: string;
43
- scan: number;
44
- plcTime: number;
45
- site: number;
46
- value: unknown;
47
- /** The site's guard operands, in the site's order. */
48
- operands: { text: string; path?: string; stable: boolean; value: unknown }[];
57
+ sequence: number;
58
+ task: string;
59
+ scan: number;
60
+ plcTime: number;
61
+ site: number;
62
+ value: unknown;
63
+ /** The site's guard operands, in the site's order. */
64
+ operands: { text: string; path?: string; stable: boolean; value: unknown }[];
49
65
  }
50
66
 
51
- /** What the program reported itself: an event, a log line or an exception. */
52
- export type AppRecord = Exclude<TelemetryRecord, { kind: "trace" }>;
67
+ export type { AppRecord };
53
68
 
54
- export interface RequestTrace {
55
- /** The server's own sequence number. */
56
- seq: number;
57
- service: string;
58
- /** From `x-tsplc-request: <job id>:<sequence>`. */
59
- job?: number;
60
- sequence?: number;
61
- startedAt: string;
62
- durationMs?: number;
63
- status: "pending" | "ok" | "error" | "timeout";
64
- httpStatus?: number;
65
- error?: string;
66
- input?: unknown;
67
- output?: unknown;
68
- }
69
+ /** One PLC service call, as the app server traced it. */
70
+ export type RequestTrace = ServiceCall;
69
71
 
70
72
  /**
71
73
  * A job as last seen. `busy` is null until it is known: from the trace's start and finish
@@ -73,81 +75,81 @@ export interface RequestTrace {
73
75
  * is busy and shown.
74
76
  */
75
77
  export interface JobState {
76
- id: number;
77
- /** Of the `busy` reading; a traced job's is good. */
78
- quality: Quality;
79
- busy: boolean | null;
80
- cancelling?: boolean;
81
- step?: number;
82
- current?: { kind: string; range: SourceRange; text: string };
83
- startedAt?: string;
84
- elapsedMs?: number;
85
- request?: { service: string; sequence: number; trace?: RequestTrace };
86
- /** Busy, but over the number of jobs whose details are read on each poll. */
87
- unread?: true;
88
- /** The last failure nothing caught, from the program's `exception` records. */
89
- failure?: { at: string; code: number; name?: string; source: string };
78
+ id: number;
79
+ /** Of the `busy` reading; a traced job's is good. */
80
+ quality: Quality;
81
+ busy: boolean | null;
82
+ cancelling?: boolean;
83
+ step?: number;
84
+ current?: { kind: string; range: SourceRange; text: string };
85
+ startedAt?: string;
86
+ elapsedMs?: number;
87
+ request?: { service: string; sequence: number; trace?: RequestTrace };
88
+ /** Busy, but over the number of jobs whose details are read on each poll. */
89
+ unread?: true;
90
+ /** The last failure nothing caught, from the program's `exception` records. */
91
+ failure?: { at: string; code: number; name?: string; source: string };
90
92
  }
91
93
 
92
94
  export interface DeviceState {
93
- id: string;
94
- /** "unknown" unless the driver's own state was read. */
95
- health: {
96
- state: "unknown" | "ok" | "fault" | "stale";
97
- value?: number;
98
- name?: string;
99
- diagnostic?: boolean;
100
- message?: string;
101
- quality: Quality;
102
- };
103
- assemblies: {
104
- direction: "input" | "output";
105
- address?: string;
106
- bytes: number[] | null;
107
- quality: Quality;
108
- }[];
109
- /** Channels bound to TypeScript I/O paths, by channel id. */
110
- channels: { id: string; path: string; value: unknown; quality: Quality }[];
111
- /** The device's hand-configured status symbols, by label. */
112
- status: Record<string, { value: unknown; quality: Quality }>;
95
+ id: string;
96
+ /** "unknown" unless the driver's own state was read. */
97
+ health: {
98
+ state: "unknown" | "ok" | "fault" | "stale";
99
+ value?: number;
100
+ name?: string;
101
+ diagnostic?: boolean;
102
+ message?: string;
103
+ quality: Quality;
104
+ };
105
+ assemblies: {
106
+ direction: "input" | "output";
107
+ address?: string;
108
+ bytes: number[] | null;
109
+ quality: Quality;
110
+ }[];
111
+ /** Channels bound to TypeScript I/O paths, by channel id. */
112
+ channels: { id: string; path: string; value: unknown; quality: Quality }[];
113
+ /** The device's hand-configured status symbols, by label. */
114
+ status: Record<string, { value: unknown; quality: Quality }>;
113
115
  }
114
116
 
115
117
  /** An entry of the "Recent" view: the server's recent window, merged with the agent's logs. */
116
118
  export type TimelineEntry = {
117
- at: string;
118
- /** Placed through another clock (the PLC's, or the app server's), so its order is approximate. */
119
- approximate: boolean;
120
- source: "plc" | "server" | "agent" | "debugger";
119
+ at: string;
120
+ /** Placed through another clock (the PLC's, or the app server's), so its order is approximate. */
121
+ approximate: boolean;
122
+ source: "plc" | "server" | "agent" | "debugger";
121
123
  } & (
122
- | { kind: "app"; task: string; sequence: number; record: AppRecord }
123
- | { kind: "trace"; trace: TraceEvent }
124
- | { kind: "request"; request: RequestTrace }
125
- | {
126
- kind: "deploy";
127
- release: string;
128
- operation: string;
129
- build?: string;
130
- user?: string;
131
- host?: string;
132
- }
133
- | {
134
- kind: "audit";
135
- /** As typed after `tsplc`, such as `force` or `reset cold`. */
136
- command: string;
137
- /** Expressions written or forced, with their values; unforced expressions map to "". */
138
- values: Record<string, string>;
139
- /** The values read just before a write or force. */
140
- previous?: Record<string, string>;
141
- user?: string;
142
- host?: string;
143
- release?: string;
144
- error?: string;
145
- }
146
- | { kind: "connection"; state: ConnectionState; error?: string }
124
+ | { kind: "app"; task: string; sequence: number; record: AppRecord }
125
+ | { kind: "trace"; trace: TraceEvent }
126
+ | { kind: "request"; request: RequestTrace }
127
+ | {
128
+ kind: "deploy";
129
+ release: string;
130
+ operation: string;
131
+ build?: string;
132
+ user?: string;
133
+ host?: string;
134
+ }
135
+ | {
136
+ kind: "audit";
137
+ /** As typed after `tsplc`, such as `force` or `reset cold`. */
138
+ command: string;
139
+ /** Expressions written or forced, with their values; unforced expressions map to "". */
140
+ values: Record<string, string>;
141
+ /** The values read just before a write or force. */
142
+ previous?: Record<string, string>;
143
+ user?: string;
144
+ host?: string;
145
+ release?: string;
146
+ error?: string;
147
+ }
148
+ | { kind: "connection"; state: ConnectionState; error?: string }
147
149
  );
148
150
 
149
151
  export interface WatchGroups {
150
- groups: Record<string, string[]>;
152
+ groups: Record<string, string[]>;
151
153
  }
152
154
 
153
155
  /**
@@ -155,29 +157,29 @@ export interface WatchGroups {
155
157
  * `health` devices, and everything of `devices`. Stream query parameters, comma-separated.
156
158
  */
157
159
  export interface Interest {
158
- watch: string[];
159
- jobs: number[];
160
- health: string[];
161
- devices: string[];
160
+ watch: string[];
161
+ jobs: number[];
162
+ health: string[];
163
+ devices: string[];
162
164
  }
163
165
 
164
166
  export interface StreamEvents {
165
- session: Session;
166
- sample: Sample;
167
- job: JobState;
168
- request: RequestTrace;
169
- device: DeviceState;
170
- timeline: TimelineEntry;
167
+ session: Session;
168
+ sample: Sample;
169
+ job: JobState;
170
+ request: RequestTrace;
171
+ device: DeviceState;
172
+ timeline: TimelineEntry;
171
173
  }
172
174
 
173
175
  /** Response bodies by route. Errors are `{ error: string }` with a 4xx or 5xx status. */
174
176
  export interface ApiResponses {
175
- "GET /api/session": Session;
176
- "GET /api/manifest": DebugManifest;
177
- "GET /api/values": Sample[];
178
- "GET /api/jobs": JobState[];
179
- "GET /api/hardware": DeviceState[];
180
- "GET /api/timeline": TimelineEntry[];
181
- "GET /api/watch": WatchGroups;
182
- "PUT /api/watch": WatchGroups;
177
+ "GET /api/session": Session;
178
+ "GET /api/manifest": DebugManifest;
179
+ "GET /api/values": Sample[];
180
+ "GET /api/jobs": JobState[];
181
+ "GET /api/hardware": DeviceState[];
182
+ "GET /api/timeline": TimelineEntry[];
183
+ "GET /api/watch": WatchGroups;
184
+ "PUT /api/watch": WatchGroups;
183
185
  }