@dronedeploy/rocos-js-sdk 4.1.1 → 4.3.0-rc.1

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.
Files changed (51) hide show
  1. package/cjs/IRocosSDK.d.ts +2 -1
  2. package/cjs/RocosSDK.d.ts +5 -1
  3. package/cjs/RocosSDK.js +9 -0
  4. package/cjs/constants/api.d.ts +8 -2
  5. package/cjs/constants/api.js +13 -5
  6. package/cjs/models/RocosError.d.ts +1 -0
  7. package/cjs/models/RocosError.js +1 -0
  8. package/cjs/models/ServiceEnum.d.ts +1 -0
  9. package/cjs/models/ServiceEnum.js +1 -0
  10. package/cjs/models/index.d.ts +1 -0
  11. package/cjs/models/index.js +1 -0
  12. package/cjs/models/maps/MapPath.d.ts +143 -0
  13. package/cjs/models/maps/MapPath.js +2 -0
  14. package/cjs/models/robot-status/RobotStatusEnums.d.ts +1 -1
  15. package/cjs/models/robot-status/RobotStatusEnums.js +1 -1
  16. package/cjs/services/MapService.d.ts +101 -0
  17. package/cjs/services/MapService.js +140 -0
  18. package/cjs/services/RobotStatusService.d.ts +37 -0
  19. package/cjs/services/RobotStatusService.js +94 -0
  20. package/cjs/services/index.d.ts +1 -0
  21. package/cjs/services/index.js +1 -0
  22. package/cjs/services/robot-status/connectivity.d.ts +76 -0
  23. package/cjs/services/robot-status/connectivity.js +140 -0
  24. package/cjs/services/robot-status/reportedStatus.d.ts +38 -0
  25. package/cjs/services/robot-status/reportedStatus.js +109 -0
  26. package/esm/IRocosSDK.d.ts +2 -1
  27. package/esm/RocosSDK.d.ts +5 -1
  28. package/esm/RocosSDK.js +10 -1
  29. package/esm/constants/api.d.ts +8 -2
  30. package/esm/constants/api.js +10 -2
  31. package/esm/models/RocosError.d.ts +1 -0
  32. package/esm/models/RocosError.js +1 -0
  33. package/esm/models/ServiceEnum.d.ts +1 -0
  34. package/esm/models/ServiceEnum.js +1 -0
  35. package/esm/models/index.d.ts +1 -0
  36. package/esm/models/index.js +1 -0
  37. package/esm/models/maps/MapPath.d.ts +143 -0
  38. package/esm/models/maps/MapPath.js +1 -0
  39. package/esm/models/robot-status/RobotStatusEnums.d.ts +1 -1
  40. package/esm/models/robot-status/RobotStatusEnums.js +1 -1
  41. package/esm/services/MapService.d.ts +101 -0
  42. package/esm/services/MapService.js +141 -1
  43. package/esm/services/RobotStatusService.d.ts +37 -0
  44. package/esm/services/RobotStatusService.js +90 -0
  45. package/esm/services/index.d.ts +1 -0
  46. package/esm/services/index.js +1 -0
  47. package/esm/services/robot-status/connectivity.d.ts +76 -0
  48. package/esm/services/robot-status/connectivity.js +131 -0
  49. package/esm/services/robot-status/reportedStatus.d.ts +38 -0
  50. package/esm/services/robot-status/reportedStatus.js +102 -0
  51. package/package.json +1 -1
@@ -28,6 +28,7 @@ export const errorCodes = {
28
28
  TARGET_SERVICE_ERROR: 'TARGET_SERVICE_ERROR',
29
29
  ENVIRONMENT_SERVICE_ERROR: 'ENVIRONMENT_SERVICE_ERROR',
30
30
  TAG_SERVICE_ERROR: 'TAG_SERVICE_ERROR',
31
+ ROBOT_STATUS_SERVICE_ERROR: 'ROBOT_STATUS_SERVICE_ERROR',
31
32
  };
32
33
  export class RocosError extends Error {
33
34
  constructor(err, code, statusCode) {
@@ -17,6 +17,7 @@ export declare enum ServiceEnum {
17
17
  PROJECT = "project",
18
18
  PROFILE = "profile",
19
19
  ROBOT = "robot",
20
+ ROBOT_STATUS = "robot_status",
20
21
  RTP_WEBRTC = "rtp_webrtc",
21
22
  SCHEDULE = "schedule",
22
23
  SEARCH = "search",
@@ -18,6 +18,7 @@ export var ServiceEnum;
18
18
  ServiceEnum["PROJECT"] = "project";
19
19
  ServiceEnum["PROFILE"] = "profile";
20
20
  ServiceEnum["ROBOT"] = "robot";
21
+ ServiceEnum["ROBOT_STATUS"] = "robot_status";
21
22
  ServiceEnum["RTP_WEBRTC"] = "rtp_webrtc";
22
23
  ServiceEnum["SCHEDULE"] = "schedule";
23
24
  ServiceEnum["SEARCH"] = "search";
@@ -51,6 +51,7 @@ export * from './maps/Map';
51
51
  export * from './maps/MapContent';
52
52
  export * from './maps/MapEdge';
53
53
  export * from './maps/MapNode';
54
+ export * from './maps/MapPath';
54
55
  export * from './maps/Panorama';
55
56
  export * from './message';
56
57
  export * from './params/ICallerParams';
@@ -51,6 +51,7 @@ export * from './maps/Map';
51
51
  export * from './maps/MapContent';
52
52
  export * from './maps/MapEdge';
53
53
  export * from './maps/MapNode';
54
+ export * from './maps/MapPath';
54
55
  export * from './maps/Panorama';
55
56
  export * from './message';
56
57
  export * from './params/ICallerParams';
@@ -0,0 +1,143 @@
1
+ import { Quaternion, Vector3 } from '../graph';
2
+ import { MapContentNode } from './MapContent';
3
+ /**
4
+ * A path (polyline or polygon) in a robot map, as returned by
5
+ * `GET /graphs/projects/{projectId}/maps/{mapId}/paths/{pathId}` — the same shape the
6
+ * rocos-agent map component's `paths/get` service reports.
7
+ *
8
+ * A path is stored as a sub-graph following the `go-common/graph/paths` convention: a parent
9
+ * node (type `path.parent.v1`, or any existing node acting as anchor) plus one member node
10
+ * per vertex, wired by `path.start.v1` / `path.belongs.v1` / `path.edge.v1` edges. The path
11
+ * id IS the parent node id.
12
+ */
13
+ export interface MapPath {
14
+ /** The path id (= parent node id). */
15
+ id: string;
16
+ /** Whether the path is a closed polygon (true) or an open polyline (false). */
17
+ closed: boolean;
18
+ /** The full parent node. */
19
+ parent: MapContentNode;
20
+ /** Ordered member (vertex) node ids, walked start → end. */
21
+ members: string[];
22
+ }
23
+ /** Filters for `MapService.listPaths`. */
24
+ export interface ListPathsFilter {
25
+ /** Only include paths with this closed flag (omit for both). */
26
+ closed?: boolean;
27
+ /**
28
+ * Only include paths whose parent node type is in this list (omit for all).
29
+ *
30
+ * Wire-format caveat: the server takes this as a single comma-separated query parameter
31
+ * (`?types=a,b`), so a node type that itself contains a comma cannot be expressed — it
32
+ * would be split into two wrong filter terms and silently match nothing. Node types are
33
+ * free-form text server-side, so this is conceivable if unlikely; avoid commas in type
34
+ * names, or filter client-side over `listPaths` + `getPath` results if you must.
35
+ */
36
+ types?: string[];
37
+ }
38
+ /**
39
+ * Body of `POST /graphs/projects/{projectId}/maps/{mapId}/paths/{pathId}/append`. Appends
40
+ * already-existing member nodes to a path, creating the path (and its `path.parent.v1`
41
+ * parent node) when absent — an existing node of any client-writable type is reused as the
42
+ * anchor instead.
43
+ *
44
+ * Members must already exist in the map (400 otherwise). `closed` is only applied while the
45
+ * path is empty; supplying a value that conflicts with a non-empty path's stored flag is
46
+ * rejected with 409 (use {@link MapService.replacePath} to change closed-ness). `data` keys
47
+ * are merged onto the parent node.
48
+ */
49
+ export interface AppendToPathRequest {
50
+ closed?: boolean;
51
+ data?: Record<string, unknown>;
52
+ members: string[];
53
+ }
54
+ /**
55
+ * A rigid-body transform positioning one path vertex relative to the frame named in the
56
+ * enclosing request. `rot` is optional and defaults to identity — path vertices are
57
+ * typically plain positions. Field naming matches {@link AffineTransform} (`pos`/`rot`);
58
+ * the service marshals onto the server's `translation`/`rotation` wire shape.
59
+ */
60
+ export interface PathPointTransform {
61
+ rot?: Quaternion;
62
+ pos: Vector3;
63
+ }
64
+ /**
65
+ * One vertex in a path payload. `id` is optional; when blank the server mints a UUID.
66
+ *
67
+ * `transform` is required by the append endpoint (which only creates vertices). In a path
68
+ * replace its presence carries the intent: supplied means the position is declarative (the
69
+ * vertex is created or — when the path exclusively owns the node — recreated at that
70
+ * position, which is how vertices are moved), while omitted means "reuse the existing node
71
+ * in place, position untouched".
72
+ */
73
+ export interface PathPoint {
74
+ id?: string;
75
+ data?: Record<string, unknown>;
76
+ transform?: PathPointTransform;
77
+ }
78
+ /**
79
+ * A {@link PathPoint} whose transform is mandatory, for the append/transformable body —
80
+ * that endpoint only creates vertices, so every point needs a position. Requiring it at the
81
+ * type level moves the server's 400 for a transform-less point to compile time.
82
+ */
83
+ export interface TransformablePathPoint extends PathPoint {
84
+ transform: PathPointTransform;
85
+ }
86
+ /**
87
+ * Body of `POST /graphs/projects/{projectId}/maps/{mapId}/paths/{pathId}/append/transformable`.
88
+ * For each point it creates a node (`nodeType`, default `FRAME`) positioned by a `TRANSFORM`
89
+ * edge from the existing `frame` node, and appends them all to the path in one transaction —
90
+ * the cloud analog of the rocos-agent's `paths/append/currentPosition`, with the caller
91
+ * supplying positions instead of the robot's live pose.
92
+ *
93
+ * Every point must carry a `transform` (enforced by {@link TransformablePathPoint}; the
94
+ * server also rejects a transform-less point with 400 — append only creates vertices; use
95
+ * {@link MapService.appendToPath} to append existing nodes). Node creation is create-only: a
96
+ * point id that already exists in the map is rejected with 409 and the whole append rolls
97
+ * back. `closed` and `data` behave as in {@link AppendToPathRequest}.
98
+ */
99
+ export interface AppendTransformablePointsRequest {
100
+ closed?: boolean;
101
+ data?: Record<string, unknown>;
102
+ frame: string;
103
+ nodeType?: string;
104
+ points: TransformablePathPoint[];
105
+ }
106
+ /** Response of the append/transformable endpoint: the created vertex ids, in path order. */
107
+ export interface AppendPathPointsResponse {
108
+ ids: string[];
109
+ }
110
+ /**
111
+ * Body of `PUT /graphs/projects/{projectId}/maps/{mapId}/paths/{pathId}` — the editor
112
+ * primitive. Declares the path's entire desired state; vertex move/insert/delete/reorder
113
+ * and closed-flag changes all reach the server as one idempotent call.
114
+ *
115
+ * The existing structure is torn down (old vertices exclusively owned by the path are
116
+ * deleted; shared members are detached, never moved or deleted; the parent node always
117
+ * survives) and rebuilt from `points`. Each point's `transform` carries its intent:
118
+ *
119
+ * - **With a transform** the position is declarative: the vertex is created (as `nodeType`,
120
+ * default `FRAME`, positioned by a `TRANSFORM` edge from `frame`), and for the path's own
121
+ * vertices same id + new transform = a move. A transform on a node the path doesn't
122
+ * exclusively own is rejected with 409.
123
+ * - **Without a transform** the point reuses an existing node in place, position untouched
124
+ * (400 if it doesn't exist) — how shared waypoints stay in the path.
125
+ *
126
+ * `parentType` applies when the parent node is created (default `path.parent.v1`); against
127
+ * an existing parent it must match (409) or be omitted (reused as-is, the anchored-path
128
+ * model). Replacing can also repair a structurally malformed path (which `getPath` reports
129
+ * as 422). Repeated identical PUTs are hash-stable: the server skips the map-timestamp bump
130
+ * and SUMMARY rewrite when the result matches what is stored.
131
+ *
132
+ * Access rules match {@link MapService.deletePath} (replace deletes vertices): the
133
+ * environment map is off-limits, the dronedeploy map is admin-only, normal maps are open to
134
+ * any caller with project access.
135
+ */
136
+ export interface ReplacePathRequest {
137
+ closed: boolean;
138
+ parentType?: string;
139
+ nodeType?: string;
140
+ data?: Record<string, unknown>;
141
+ frame?: string;
142
+ points: PathPoint[];
143
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -45,7 +45,7 @@ export declare enum ServiceConnection {
45
45
  * expected services.
46
46
  */
47
47
  export declare enum RobotConnectivity {
48
- /** Every expected service reports connected. */
48
+ /** At least one expected service is connected and none is disconnected. */
49
49
  ONLINE = "online",
50
50
  /** Some, but not all, expected services report connected. */
51
51
  DEGRADED = "degraded",
@@ -49,7 +49,7 @@ export var ServiceConnection;
49
49
  */
50
50
  export var RobotConnectivity;
51
51
  (function (RobotConnectivity) {
52
- /** Every expected service reports connected. */
52
+ /** At least one expected service is connected and none is disconnected. */
53
53
  RobotConnectivity["ONLINE"] = "online";
54
54
  /** Some, but not all, expected services report connected. */
55
55
  RobotConnectivity["DEGRADED"] = "degraded";
@@ -1,6 +1,7 @@
1
1
  import { AddEdgeRequest, AddEdgeResponse, AddTransformEdgeRequest } from '../models/maps/MapEdge';
2
2
  import { AddNodeRequest, AddNodeResponse, AddTransformableNodeRequest } from '../models/maps/MapNode';
3
3
  import { AddPanoramaRequest, AddPanoramaResponse, CreateObservation, Observation } from '../models/maps/Panorama';
4
+ import { AppendPathPointsResponse, AppendToPathRequest, AppendTransformablePointsRequest, ListPathsFilter, MapPath, ReplacePathRequest } from '../models/maps/MapPath';
4
5
  import { Asset, IBaseService, IRocosSDKConfig, Map, MapContent, RocosError } from '../models';
5
6
  import { BaseServiceAbstract } from './BaseServiceAbstract';
6
7
  /**
@@ -334,4 +335,104 @@ export declare class MapService extends BaseServiceAbstract implements IBaseServ
334
335
  * @param edgeId The ID of the edge to delete.
335
336
  */
336
337
  deleteEdge(projectId: string, mapId: string, edgeId: string): Promise<void>;
338
+ /**
339
+ * List the paths (polylines/polygons) in a map. A path is a sub-graph following the
340
+ * `go-common/graph/paths` convention shared with the rocos-agent's map component; this
341
+ * mirrors the agent's `paths/list` service, returning the parent node ids of every path
342
+ * that survives the filters.
343
+ *
344
+ * @param projectId The ID of the project the map belongs to.
345
+ * @param mapId The ID of the map to list paths from.
346
+ * @param filter Optional closed-flag and parent-node-type filters. The type filter goes
347
+ * over the wire as one comma-separated query parameter, so types containing a comma
348
+ * cannot be expressed (see {@link ListPathsFilter.types}).
349
+ * @returns The path ids (= parent node ids), sorted.
350
+ */
351
+ listPaths(projectId: string, mapId: string, filter?: ListPathsFilter): Promise<string[]>;
352
+ /**
353
+ * Get one path: its closed flag, full parent node, and ordered member node ids — the same
354
+ * shape as the agent's `paths/get` response. An existing node with no path structure is
355
+ * reported as an empty open path; a missing node is 404; stored structure violating the
356
+ * path convention (e.g. multiple start edges) is 422 (repair it with {@link replacePath}).
357
+ *
358
+ * @param projectId The ID of the project the map belongs to.
359
+ * @param mapId The ID of the map the path lives in.
360
+ * @param pathId The path id (= parent node id).
361
+ */
362
+ getPath(projectId: string, mapId: string, pathId: string): Promise<MapPath>;
363
+ /**
364
+ * Append already-existing member nodes to a path, creating the path when absent —
365
+ * mirroring the agent's `paths/append`. Members must already exist (400 otherwise);
366
+ * `path.index` numbering continues from the existing member count. A `closed` value
367
+ * conflicting with a non-empty path's stored flag is rejected with 409 (unlike the agent,
368
+ * which silently ignores it) — change closed-ness with {@link replacePath}.
369
+ *
370
+ * @param projectId The ID of the project the map belongs to.
371
+ * @param mapId The ID of the map the path lives in.
372
+ * @param pathId The path id (= parent node id).
373
+ * @param body The members to append, plus optional closed flag and parent data.
374
+ */
375
+ appendToPath(projectId: string, mapId: string, pathId: string, body: AppendToPathRequest): Promise<void>;
376
+ /**
377
+ * Create one positioned vertex node per point and append them all to a path in one
378
+ * transaction — the cloud analog of the agent's `paths/append/currentPosition`, with the
379
+ * caller supplying positions instead of the robot's live pose. Every point must carry a
380
+ * transform (append only creates; use {@link appendToPath} for existing nodes); a point id
381
+ * that already exists is a 409 and the whole append rolls back.
382
+ *
383
+ * Wire-shape note: the server receives each point's transform as
384
+ * `{ rotation, translation }`. This method marshals the caller-facing `rot`/`pos`
385
+ * (matching the node/panorama transform naming) onto that shape before POSTing.
386
+ *
387
+ * @param projectId The ID of the project the map belongs to.
388
+ * @param mapId The ID of the map the path lives in.
389
+ * @param pathId The path id (= parent node id).
390
+ * @param body The frame, points, and optional node type / closed flag / parent data.
391
+ * @returns The created vertex node ids, in path order (server-minted UUIDs for blank ids).
392
+ */
393
+ appendTransformablePointsToPath(projectId: string, mapId: string, pathId: string, body: AppendTransformablePointsRequest): Promise<AppendPathPointsResponse>;
394
+ /**
395
+ * Replace a path's entire structure in one idempotent call — the editor primitive for
396
+ * vertex move/insert/delete/reorder and closed-flag changes. See {@link ReplacePathRequest}
397
+ * for the full semantics; the essentials:
398
+ *
399
+ * - A point WITH a transform declares its position; for the path's own vertices, same id +
400
+ * new transform = a move. A transform on a node the path doesn't exclusively own is 409.
401
+ * - A point WITHOUT a transform reuses an existing node in place (400 if missing).
402
+ * - Old vertices exclusively owned by the path and not re-referenced are deleted; shared
403
+ * members are detached, never moved or deleted.
404
+ * - `parentType` must match an existing parent (409) or be omitted; it applies on create.
405
+ *
406
+ * @param projectId The ID of the project the map belongs to.
407
+ * @param mapId The ID of the map the path lives in.
408
+ * @param pathId The path id (= parent node id).
409
+ * @param body The path's desired state.
410
+ */
411
+ replacePath(projectId: string, mapId: string, pathId: string, body: ReplacePathRequest): Promise<void>;
412
+ /**
413
+ * Delete a path's structure, mirroring the agent's `paths/delete`: idempotent (a missing
414
+ * path still returns success), member nodes preserved by default, and the parent node
415
+ * itself deleted only when it is a pure `path.parent.v1` (an anchored path keeps its
416
+ * anchor node, minus the path edges).
417
+ *
418
+ * With `deleteMembers`, member nodes exclusively owned by the path (no remaining edges
419
+ * beyond their positioning `TRANSFORM`) are also removed; anything referenced elsewhere
420
+ * survives. Access rules match {@link deleteNode}: environment off-limits, dronedeploy
421
+ * admin-only, normal maps open to any caller with project access.
422
+ *
423
+ * @param projectId The ID of the project the map belongs to.
424
+ * @param mapId The ID of the map the path lives in.
425
+ * @param pathId The path id (= parent node id).
426
+ * @param opts Set `deleteMembers` to also remove exclusively-owned vertex nodes.
427
+ */
428
+ deletePath(projectId: string, mapId: string, pathId: string, opts?: {
429
+ deleteMembers?: boolean;
430
+ }): Promise<void>;
431
+ /**
432
+ * Marshal a caller-facing {@link PathPoint} onto the server's wire shape: `rot`/`pos`
433
+ * become `rotation`/`translation`, and an absent transform stays absent (its presence
434
+ * carries intent in a replace). A missing `rot` is left for the server to default to
435
+ * identity.
436
+ */
437
+ private pathPointToWire;
337
438
  }
@@ -1,4 +1,4 @@
1
- import { API_GRAPHS_MAPS_COPY_URL, API_GRAPHS_MAPS_DEPLOYED_URL, API_GRAPHS_MAPS_DEPLOY_URL, API_GRAPHS_MAPS_GEOJSON_URL, API_GRAPHS_MAPS_MERGE_URL, API_GRAPHS_MAPS_NEW_URL, API_GRAPHS_MAPS_URL, API_GRAPHS_MAP_CONTENT_URL, API_GRAPHS_MAP_EDGES_ADD_TRANSFORM_URL, API_GRAPHS_MAP_EDGES_ADD_URL, API_GRAPHS_MAP_EDGE_URL, API_GRAPHS_MAP_ID_URL, API_GRAPHS_MAP_METADATA_URL, API_GRAPHS_MAP_NODES_ADD_TRANSFORMABLE_URL, API_GRAPHS_MAP_NODES_ADD_URL, API_GRAPHS_MAP_NODE_URL, API_GRAPHS_OBSERVATIONS_URL, API_GRAPHS_OBSERVATION_KEYS_URL, API_GRAPHS_PANORAMA, API_GRAPHS_PANORAMAS_URL, API_GRAPHS_PANORAMA_OBSERVATIONS_URL, } from '../constants/api';
1
+ import { API_GRAPHS_MAPS_COPY_URL, API_GRAPHS_MAPS_DEPLOYED_URL, API_GRAPHS_MAPS_DEPLOY_URL, API_GRAPHS_MAPS_GEOJSON_URL, API_GRAPHS_MAPS_MERGE_URL, API_GRAPHS_MAPS_NEW_URL, API_GRAPHS_MAPS_URL, API_GRAPHS_MAP_CONTENT_URL, API_GRAPHS_MAP_EDGES_ADD_TRANSFORM_URL, API_GRAPHS_MAP_EDGES_ADD_URL, API_GRAPHS_MAP_EDGE_URL, API_GRAPHS_MAP_ID_URL, API_GRAPHS_MAP_METADATA_URL, API_GRAPHS_MAP_NODES_ADD_TRANSFORMABLE_URL, API_GRAPHS_MAP_NODES_ADD_URL, API_GRAPHS_MAP_NODE_URL, API_GRAPHS_MAP_PATHS_URL, API_GRAPHS_MAP_PATH_APPEND_TRANSFORMABLE_URL, API_GRAPHS_MAP_PATH_APPEND_URL, API_GRAPHS_MAP_PATH_URL, API_GRAPHS_OBSERVATIONS_URL, API_GRAPHS_OBSERVATION_KEYS_URL, API_GRAPHS_PANORAMA, API_GRAPHS_PANORAMAS_URL, API_GRAPHS_PANORAMA_OBSERVATIONS_URL, } from '../constants/api';
2
2
  import { RocosError, errorCodes } from '../models';
3
3
  import { BaseServiceAbstract } from './BaseServiceAbstract';
4
4
  import { RocosLogger } from '../logger/RocosLogger';
@@ -451,4 +451,144 @@ export class MapService extends BaseServiceAbstract {
451
451
  deleteEdge(projectId, mapId, edgeId) {
452
452
  return this.callDelete(formatServiceUrl(API_GRAPHS_MAP_EDGE_URL, { url: this.config.url, projectId, mapId, edgeId }, this.config.insecure), 'Failed to delete edge.');
453
453
  }
454
+ /**
455
+ * List the paths (polylines/polygons) in a map. A path is a sub-graph following the
456
+ * `go-common/graph/paths` convention shared with the rocos-agent's map component; this
457
+ * mirrors the agent's `paths/list` service, returning the parent node ids of every path
458
+ * that survives the filters.
459
+ *
460
+ * @param projectId The ID of the project the map belongs to.
461
+ * @param mapId The ID of the map to list paths from.
462
+ * @param filter Optional closed-flag and parent-node-type filters. The type filter goes
463
+ * over the wire as one comma-separated query parameter, so types containing a comma
464
+ * cannot be expressed (see {@link ListPathsFilter.types}).
465
+ * @returns The path ids (= parent node ids), sorted.
466
+ */
467
+ async listPaths(projectId, mapId, filter) {
468
+ const queryParams = {};
469
+ if (filter?.closed !== undefined)
470
+ queryParams.closed = filter.closed.toString();
471
+ if (filter?.types?.length)
472
+ queryParams.types = filter.types.join(',');
473
+ const resp = await this.callGet(formatServiceUrl(API_GRAPHS_MAP_PATHS_URL, { url: this.config.url, projectId, mapId }, this.config.insecure), 'Failed to list paths.', queryParams);
474
+ return resp.paths;
475
+ }
476
+ /**
477
+ * Get one path: its closed flag, full parent node, and ordered member node ids — the same
478
+ * shape as the agent's `paths/get` response. An existing node with no path structure is
479
+ * reported as an empty open path; a missing node is 404; stored structure violating the
480
+ * path convention (e.g. multiple start edges) is 422 (repair it with {@link replacePath}).
481
+ *
482
+ * @param projectId The ID of the project the map belongs to.
483
+ * @param mapId The ID of the map the path lives in.
484
+ * @param pathId The path id (= parent node id).
485
+ */
486
+ getPath(projectId, mapId, pathId) {
487
+ return this.callGet(formatServiceUrl(API_GRAPHS_MAP_PATH_URL, { url: this.config.url, projectId, mapId, pathId }, this.config.insecure), 'Failed to get path.');
488
+ }
489
+ /**
490
+ * Append already-existing member nodes to a path, creating the path when absent —
491
+ * mirroring the agent's `paths/append`. Members must already exist (400 otherwise);
492
+ * `path.index` numbering continues from the existing member count. A `closed` value
493
+ * conflicting with a non-empty path's stored flag is rejected with 409 (unlike the agent,
494
+ * which silently ignores it) — change closed-ness with {@link replacePath}.
495
+ *
496
+ * @param projectId The ID of the project the map belongs to.
497
+ * @param mapId The ID of the map the path lives in.
498
+ * @param pathId The path id (= parent node id).
499
+ * @param body The members to append, plus optional closed flag and parent data.
500
+ */
501
+ async appendToPath(projectId, mapId, pathId, body) {
502
+ await this.callPost(formatServiceUrl(API_GRAPHS_MAP_PATH_APPEND_URL, { url: this.config.url, projectId, mapId, pathId }, this.config.insecure), body, 'Failed to append to path.');
503
+ }
504
+ /**
505
+ * Create one positioned vertex node per point and append them all to a path in one
506
+ * transaction — the cloud analog of the agent's `paths/append/currentPosition`, with the
507
+ * caller supplying positions instead of the robot's live pose. Every point must carry a
508
+ * transform (append only creates; use {@link appendToPath} for existing nodes); a point id
509
+ * that already exists is a 409 and the whole append rolls back.
510
+ *
511
+ * Wire-shape note: the server receives each point's transform as
512
+ * `{ rotation, translation }`. This method marshals the caller-facing `rot`/`pos`
513
+ * (matching the node/panorama transform naming) onto that shape before POSTing.
514
+ *
515
+ * @param projectId The ID of the project the map belongs to.
516
+ * @param mapId The ID of the map the path lives in.
517
+ * @param pathId The path id (= parent node id).
518
+ * @param body The frame, points, and optional node type / closed flag / parent data.
519
+ * @returns The created vertex node ids, in path order (server-minted UUIDs for blank ids).
520
+ */
521
+ appendTransformablePointsToPath(projectId, mapId, pathId, body) {
522
+ const wireBody = {
523
+ closed: body.closed,
524
+ data: body.data,
525
+ frame: body.frame,
526
+ nodeType: body.nodeType,
527
+ points: body.points.map((p) => this.pathPointToWire(p)),
528
+ };
529
+ return this.callPost(formatServiceUrl(API_GRAPHS_MAP_PATH_APPEND_TRANSFORMABLE_URL, { url: this.config.url, projectId, mapId, pathId }, this.config.insecure), wireBody, 'Failed to append points to path.');
530
+ }
531
+ /**
532
+ * Replace a path's entire structure in one idempotent call — the editor primitive for
533
+ * vertex move/insert/delete/reorder and closed-flag changes. See {@link ReplacePathRequest}
534
+ * for the full semantics; the essentials:
535
+ *
536
+ * - A point WITH a transform declares its position; for the path's own vertices, same id +
537
+ * new transform = a move. A transform on a node the path doesn't exclusively own is 409.
538
+ * - A point WITHOUT a transform reuses an existing node in place (400 if missing).
539
+ * - Old vertices exclusively owned by the path and not re-referenced are deleted; shared
540
+ * members are detached, never moved or deleted.
541
+ * - `parentType` must match an existing parent (409) or be omitted; it applies on create.
542
+ *
543
+ * @param projectId The ID of the project the map belongs to.
544
+ * @param mapId The ID of the map the path lives in.
545
+ * @param pathId The path id (= parent node id).
546
+ * @param body The path's desired state.
547
+ */
548
+ async replacePath(projectId, mapId, pathId, body) {
549
+ const wireBody = {
550
+ closed: body.closed,
551
+ parentType: body.parentType,
552
+ nodeType: body.nodeType,
553
+ data: body.data,
554
+ frame: body.frame,
555
+ points: body.points.map((p) => this.pathPointToWire(p)),
556
+ };
557
+ await this.callPut(formatServiceUrl(API_GRAPHS_MAP_PATH_URL, { url: this.config.url, projectId, mapId, pathId }, this.config.insecure), wireBody, 'Failed to replace path.');
558
+ }
559
+ /**
560
+ * Delete a path's structure, mirroring the agent's `paths/delete`: idempotent (a missing
561
+ * path still returns success), member nodes preserved by default, and the parent node
562
+ * itself deleted only when it is a pure `path.parent.v1` (an anchored path keeps its
563
+ * anchor node, minus the path edges).
564
+ *
565
+ * With `deleteMembers`, member nodes exclusively owned by the path (no remaining edges
566
+ * beyond their positioning `TRANSFORM`) are also removed; anything referenced elsewhere
567
+ * survives. Access rules match {@link deleteNode}: environment off-limits, dronedeploy
568
+ * admin-only, normal maps open to any caller with project access.
569
+ *
570
+ * @param projectId The ID of the project the map belongs to.
571
+ * @param mapId The ID of the map the path lives in.
572
+ * @param pathId The path id (= parent node id).
573
+ * @param opts Set `deleteMembers` to also remove exclusively-owned vertex nodes.
574
+ */
575
+ deletePath(projectId, mapId, pathId, opts) {
576
+ let url = formatServiceUrl(API_GRAPHS_MAP_PATH_URL, { url: this.config.url, projectId, mapId, pathId }, this.config.insecure);
577
+ if (opts?.deleteMembers)
578
+ url += '?deleteMembers=true';
579
+ return this.callDelete(url, 'Failed to delete path.');
580
+ }
581
+ /**
582
+ * Marshal a caller-facing {@link PathPoint} onto the server's wire shape: `rot`/`pos`
583
+ * become `rotation`/`translation`, and an absent transform stays absent (its presence
584
+ * carries intent in a replace). A missing `rot` is left for the server to default to
585
+ * identity.
586
+ */
587
+ pathPointToWire(p) {
588
+ return {
589
+ id: p.id,
590
+ data: p.data,
591
+ transform: p.transform ? { rotation: p.transform.rot, translation: p.transform.pos } : undefined,
592
+ };
593
+ }
454
594
  }
@@ -0,0 +1,37 @@
1
+ import { IBaseService, IRocosSDKConfig, RobotConnectivityStatus, RobotStatus, RocosError } from '../models';
2
+ import { Observable } from 'rxjs';
3
+ import { ReportedRobotStatus } from './robot-status/reportedStatus';
4
+ import { BaseServiceAbstract } from './BaseServiceAbstract';
5
+ /** Per-call tuning for the robot status observables. */
6
+ export interface RobotStatusOptions {
7
+ /** Services whose connectivity gates ONLINE/DEGRADED. Defaults to the standard expected-services set. */
8
+ expectedServices?: string[];
9
+ /** How long without a heartbeat before telemetry-liveness is considered dead (ms). */
10
+ heartbeatTimeoutMs?: number;
11
+ /** How often the connections endpoints are polled (ms, floored internally). */
12
+ connectivityPollMs?: number;
13
+ }
14
+ /**
15
+ * The single source of truth for a robot's status. It composes the reported
16
+ * status (health/readiness from the heartbeat), per-service connectivity, and
17
+ * the canonical indicator colour, so consumers subscribe to one observable
18
+ * rather than deriving "is the robot online" themselves.
19
+ */
20
+ export declare class RobotStatusService extends BaseServiceAbstract implements IBaseService {
21
+ constructor(config: IRocosSDKConfig);
22
+ getStatus(): boolean;
23
+ /** Health + readiness as reported by the robot (new topic, legacy heartbeat fallback). */
24
+ getReportedStatusChanges(projectId: string, callsign: string): Observable<ReportedRobotStatus>;
25
+ /** Per-service connectivity plus the aggregate verdict, polled. */
26
+ getConnectivityChanges(projectId: string, callsign: string, opts?: RobotStatusOptions): Observable<RobotConnectivityStatus>;
27
+ /** One-shot connectivity snapshot: resolves once every expected service is known, or after a timeout. */
28
+ getConnectivity(projectId: string, callsign: string, opts?: RobotStatusOptions): Promise<RobotConnectivityStatus>;
29
+ /**
30
+ * The headline stream: the combined {@link RobotStatus} including the canonical
31
+ * colour token. This is what status indicators subscribe to.
32
+ */
33
+ getRobotStatusChanges(projectId: string, callsign: string, opts?: RobotStatusOptions): Observable<RobotStatus>;
34
+ protected getError(e: Error): RocosError;
35
+ private get telemetryService();
36
+ private connectivityDeps;
37
+ }
@@ -0,0 +1,90 @@
1
+ import { getConnectivityChanges } from './robot-status/connectivity';
2
+ import { RobotHealth, RobotReadiness, RocosError, ServiceConnection, errorCodes, } from '../models';
3
+ import { combineLatest, distinctUntilChanged, first, firstValueFrom, map, of, shareReplay, startWith, take, tap, timeout, } from 'rxjs';
4
+ import { getReportedStatusChanges, getTelemetryLiveness } from './robot-status/reportedStatus';
5
+ import { BaseServiceAbstract } from './BaseServiceAbstract';
6
+ import { RocosLogger } from '../logger/RocosLogger';
7
+ import { RocosStore } from '../store/RocosStore';
8
+ import { getRobotStatusColour } from '../helpers/getRobotStatusColour';
9
+ /** Upper bound on how long the one-shot {@link RobotStatusService.getConnectivity} waits to settle. */
10
+ const ONE_SHOT_TIMEOUT_MS = 10000;
11
+ const isKnown = (status) => {
12
+ return Object.values(status.services).every((connection) => connection !== ServiceConnection.UNKNOWN);
13
+ };
14
+ const robotStatusEquals = (a, b) => {
15
+ if (a.health !== b.health || a.readiness !== b.readiness)
16
+ return false;
17
+ if (a.connectivity.overall !== b.connectivity.overall)
18
+ return false;
19
+ const keys = Object.keys(a.connectivity.services);
20
+ if (keys.length !== Object.keys(b.connectivity.services).length)
21
+ return false;
22
+ return keys.every((key) => a.connectivity.services[key] === b.connectivity.services[key]);
23
+ };
24
+ /**
25
+ * The single source of truth for a robot's status. It composes the reported
26
+ * status (health/readiness from the heartbeat), per-service connectivity, and
27
+ * the canonical indicator colour, so consumers subscribe to one observable
28
+ * rather than deriving "is the robot online" themselves.
29
+ */
30
+ export class RobotStatusService extends BaseServiceAbstract {
31
+ constructor(config) {
32
+ super(config);
33
+ this.logger = RocosLogger.getInstance(`RobotStatusService(${this.config.url})`);
34
+ }
35
+ getStatus() {
36
+ return true;
37
+ }
38
+ /** Health + readiness as reported by the robot (new topic, legacy heartbeat fallback). */
39
+ getReportedStatusChanges(projectId, callsign) {
40
+ return getReportedStatusChanges(this.telemetryService, projectId, callsign);
41
+ }
42
+ /** Per-service connectivity plus the aggregate verdict, polled. */
43
+ getConnectivityChanges(projectId, callsign, opts) {
44
+ return getConnectivityChanges(this.connectivityDeps(projectId, callsign, opts), projectId, callsign, opts?.expectedServices, opts?.connectivityPollMs);
45
+ }
46
+ /** One-shot connectivity snapshot: resolves once every expected service is known, or after a timeout. */
47
+ getConnectivity(projectId, callsign, opts) {
48
+ // Capture the latest snapshot explicitly: on timeout, refCount teardown would otherwise
49
+ // hand a fresh (all-UNKNOWN seed) re-subscription to the fallback rather than the last value.
50
+ let latest;
51
+ const changes$ = this.getConnectivityChanges(projectId, callsign, opts).pipe(tap((status) => {
52
+ latest = status;
53
+ }), shareReplay({ bufferSize: 1, refCount: true }));
54
+ return firstValueFrom(changes$.pipe(first(isKnown),
55
+ // Don't wait forever on a persistently-unknown service — fall back to the latest snapshot seen.
56
+ timeout({ first: ONE_SHOT_TIMEOUT_MS, with: () => (latest ? of(latest) : changes$.pipe(take(1))) })));
57
+ }
58
+ /**
59
+ * The headline stream: the combined {@link RobotStatus} including the canonical
60
+ * colour token. This is what status indicators subscribe to.
61
+ */
62
+ getRobotStatusChanges(projectId, callsign, opts) {
63
+ const reported$ = this.getReportedStatusChanges(projectId, callsign).pipe(
64
+ // Seed so the combined stream emits (e.g. gray) before the first heartbeat arrives.
65
+ startWith({ health: RobotHealth.UNKNOWN, readiness: RobotReadiness.UNKNOWN }));
66
+ const connectivity$ = this.getConnectivityChanges(projectId, callsign, opts);
67
+ return combineLatest([reported$, connectivity$]).pipe(map(([reported, connectivity]) => ({
68
+ health: reported.health,
69
+ readiness: reported.readiness,
70
+ connectivity,
71
+ colour: getRobotStatusColour({ health: reported.health, readiness: reported.readiness, connectivity }),
72
+ })), distinctUntilChanged(robotStatusEquals));
73
+ }
74
+ getError(e) {
75
+ return new RocosError(e, errorCodes.ROBOT_STATUS_SERVICE_ERROR);
76
+ }
77
+ get telemetryService() {
78
+ return RocosStore.getSDKInstance(this.config).getTelemetryService();
79
+ }
80
+ connectivityDeps(projectId, callsign, opts) {
81
+ return {
82
+ httpGet: (url) => {
83
+ return this.callGet(url, `Failed to get connection status for ${callsign} in project ${projectId}.`);
84
+ },
85
+ baseUrl: this.config.url,
86
+ insecure: this.config.insecure,
87
+ telemetryLiveness$: getTelemetryLiveness(this.telemetryService, projectId, callsign, opts?.heartbeatTimeoutMs),
88
+ };
89
+ }
90
+ }
@@ -17,6 +17,7 @@ export * from './ProfileService';
17
17
  export * from './ProjectService';
18
18
  export * from './RTPWebRTCService';
19
19
  export * from './RobotService';
20
+ export * from './RobotStatusService';
20
21
  export * from './ScheduleService';
21
22
  export * from './SearchService';
22
23
  export * from './SpotProvisioningService';
@@ -17,6 +17,7 @@ export * from './ProfileService';
17
17
  export * from './ProjectService';
18
18
  export * from './RTPWebRTCService';
19
19
  export * from './RobotService';
20
+ export * from './RobotStatusService';
20
21
  export * from './ScheduleService';
21
22
  export * from './SearchService';
22
23
  export * from './SpotProvisioningService';