@dronedeploy/rocos-js-sdk 4.4.16-rc.1 → 4.5.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.
@@ -35,12 +35,20 @@ export interface RobotStatusOptions {
35
35
  * rather than deriving "is the robot online" themselves.
36
36
  */
37
37
  export declare class RobotStatusService extends BaseServiceAbstract implements IBaseService {
38
+ private platformTime;
38
39
  constructor(config: IRocosSDKConfig);
39
40
  getStatus(): boolean;
40
41
  /** Health + readiness as reported by the robot (new topic, legacy heartbeat fallback). */
41
42
  getReportedStatusChanges(projectId: string, callsign: string): Observable<ReportedRobotStatus>;
42
43
  /** Per-contributor breakdown behind the reported health and readiness, with the reason for each. */
43
44
  getStatusContributorsChanges(projectId: string, callsign: string): Observable<RobotStatusContributors>;
45
+ /**
46
+ * Telemetry latency in milliseconds — platform time minus when the agent created each liveness
47
+ * message (`robot/status`, or the legacy heartbeat). Emits once per message, and nothing while
48
+ * none arrive: pair it with the `telemetry-liveness` connectivity service to tell a stale value
49
+ * from a live one.
50
+ */
51
+ getTelemetryLatencyChanges(projectId: string, callsign: string): Observable<number>;
44
52
  /** Per-service connectivity plus the aggregate verdict, polled. */
45
53
  getConnectivityChanges(projectId: string, callsign: string, opts?: RobotStatusOptions): Observable<RobotConnectivityStatus>;
46
54
  /** One-shot connectivity snapshot: resolves once every expected service is known, or after a timeout. */
@@ -6,6 +6,7 @@ const models_1 = require("../models");
6
6
  const rxjs_1 = require("rxjs");
7
7
  const reportedStatus_1 = require("./robot-status/reportedStatus");
8
8
  const BaseServiceAbstract_1 = require("./BaseServiceAbstract");
9
+ const PlatformTimeService_1 = require("./PlatformTimeService");
9
10
  const RocosLogger_1 = require("../logger/RocosLogger");
10
11
  const RocosStore_1 = require("../store/RocosStore");
11
12
  const getRobotStatusColour_1 = require("../helpers/getRobotStatusColour");
@@ -34,6 +35,7 @@ class RobotStatusService extends BaseServiceAbstract_1.BaseServiceAbstract {
34
35
  constructor(config) {
35
36
  super(config);
36
37
  this.logger = RocosLogger_1.RocosLogger.getInstance(`RobotStatusService(${this.config.url})`);
38
+ this.platformTime = PlatformTimeService_1.PlatFormTimeService.getInstance(RocosStore_1.RocosStore.getSDKInstance(this.config).getTimeSyncerService());
37
39
  }
38
40
  getStatus() {
39
41
  return true;
@@ -46,6 +48,15 @@ class RobotStatusService extends BaseServiceAbstract_1.BaseServiceAbstract {
46
48
  getStatusContributorsChanges(projectId, callsign) {
47
49
  return (0, reportedStatus_1.getStatusContributorsChanges)(this.telemetryService, projectId, callsign);
48
50
  }
51
+ /**
52
+ * Telemetry latency in milliseconds — platform time minus when the agent created each liveness
53
+ * message (`robot/status`, or the legacy heartbeat). Emits once per message, and nothing while
54
+ * none arrive: pair it with the `telemetry-liveness` connectivity service to tell a stale value
55
+ * from a live one.
56
+ */
57
+ getTelemetryLatencyChanges(projectId, callsign) {
58
+ return (0, reportedStatus_1.getTelemetryLatencyChanges)(this.telemetryService, projectId, callsign, () => this.platformTime.platformTime);
59
+ }
49
60
  /** Per-service connectivity plus the aggregate verdict, polled. */
50
61
  getConnectivityChanges(projectId, callsign, opts) {
51
62
  return (0, connectivity_1.getConnectivityChanges)(this.connectivityDeps(projectId, callsign, opts), projectId, callsign, opts?.expectedServices, opts?.connectivityPollMs);
@@ -41,6 +41,18 @@ export declare const getReportedStatusChanges: (telemetry: TelemetryService, pro
41
41
  * error falls back to an empty breakdown rather than terminating the stream.
42
42
  */
43
43
  export declare const getStatusContributorsChanges: (telemetry: TelemetryService, projectId: string, callsign: string) => Observable<RobotStatusContributors>;
44
+ /**
45
+ * Emits the robot's telemetry latency in milliseconds, once per liveness message (from either the
46
+ * new `robot/status` topic or the legacy heartbeat — the same messages {@link getTelemetryLiveness}
47
+ * watches): `now()` minus the time the agent created the message.
48
+ *
49
+ * `now` should return platform time, so the measurement isn't skewed by the client's clock. Any
50
+ * remaining offset between the agent's clock and platform time feeds straight through, so a value
51
+ * can be slightly negative. Nothing is emitted while no messages arrive; pair this with
52
+ * {@link getTelemetryLiveness} to tell a stale value from a live one. A telemetry error completes
53
+ * the stream rather than erroring it.
54
+ */
55
+ export declare const getTelemetryLatencyChanges: (telemetry: TelemetryService, projectId: string, callsign: string, now: () => number) => Observable<number>;
44
56
  /**
45
57
  * Emits the `telemetry-liveness` connectivity signal: whether a heartbeat (from
46
58
  * either the new `robot/status` topic or the legacy heartbeat) has been received
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getTelemetryLiveness = exports.getStatusContributorsChanges = exports.getReportedStatusChanges = exports.parseRobotReadiness = exports.parseRobotHealth = exports.ROBOT_STATUS_CONTRIBUTORS_SOURCE = exports.LEGACY_HEARTBEAT_SOURCE = exports.ROBOT_STATUS_SOURCE = void 0;
3
+ exports.getTelemetryLiveness = exports.getTelemetryLatencyChanges = exports.getStatusContributorsChanges = exports.getReportedStatusChanges = exports.parseRobotReadiness = exports.parseRobotHealth = exports.ROBOT_STATUS_CONTRIBUTORS_SOURCE = exports.LEGACY_HEARTBEAT_SOURCE = exports.ROBOT_STATUS_SOURCE = void 0;
4
4
  const rxjs_1 = require("rxjs");
5
5
  const models_1 = require("../../models");
6
6
  /** The new agent topic carrying health + readiness (replaces the heartbeat). */
@@ -119,6 +119,23 @@ const getStatusContributorsChanges = (telemetry, projectId, callsign) => {
119
119
  }), (0, rxjs_1.startWith)(EMPTY_CONTRIBUTORS), (0, rxjs_1.distinctUntilChanged)((a, b) => JSON.stringify(a) === JSON.stringify(b)), (0, rxjs_1.catchError)(() => (0, rxjs_1.of)(EMPTY_CONTRIBUTORS)));
120
120
  };
121
121
  exports.getStatusContributorsChanges = getStatusContributorsChanges;
122
+ /**
123
+ * Emits the robot's telemetry latency in milliseconds, once per liveness message (from either the
124
+ * new `robot/status` topic or the legacy heartbeat — the same messages {@link getTelemetryLiveness}
125
+ * watches): `now()` minus the time the agent created the message.
126
+ *
127
+ * `now` should return platform time, so the measurement isn't skewed by the client's clock. Any
128
+ * remaining offset between the agent's clock and platform time feeds straight through, so a value
129
+ * can be slightly negative. Nothing is emitted while no messages arrive; pair this with
130
+ * {@link getTelemetryLiveness} to tell a stale value from a live one. A telemetry error completes
131
+ * the stream rather than erroring it.
132
+ */
133
+ const getTelemetryLatencyChanges = (telemetry, projectId, callsign, now) => {
134
+ return telemetry
135
+ .subscribe({ projectId, callsigns: [callsign], sources: [exports.ROBOT_STATUS_SOURCE, exports.LEGACY_HEARTBEAT_SOURCE] })
136
+ .pipe((0, rxjs_1.map)((message) => now() - message.createdAt.getTime()), (0, rxjs_1.catchError)(() => rxjs_1.EMPTY));
137
+ };
138
+ exports.getTelemetryLatencyChanges = getTelemetryLatencyChanges;
122
139
  /**
123
140
  * Emits the `telemetry-liveness` connectivity signal: whether a heartbeat (from
124
141
  * either the new `robot/status` topic or the legacy heartbeat) has been received
@@ -35,12 +35,20 @@ export interface RobotStatusOptions {
35
35
  * rather than deriving "is the robot online" themselves.
36
36
  */
37
37
  export declare class RobotStatusService extends BaseServiceAbstract implements IBaseService {
38
+ private platformTime;
38
39
  constructor(config: IRocosSDKConfig);
39
40
  getStatus(): boolean;
40
41
  /** Health + readiness as reported by the robot (new topic, legacy heartbeat fallback). */
41
42
  getReportedStatusChanges(projectId: string, callsign: string): Observable<ReportedRobotStatus>;
42
43
  /** Per-contributor breakdown behind the reported health and readiness, with the reason for each. */
43
44
  getStatusContributorsChanges(projectId: string, callsign: string): Observable<RobotStatusContributors>;
45
+ /**
46
+ * Telemetry latency in milliseconds — platform time minus when the agent created each liveness
47
+ * message (`robot/status`, or the legacy heartbeat). Emits once per message, and nothing while
48
+ * none arrive: pair it with the `telemetry-liveness` connectivity service to tell a stale value
49
+ * from a live one.
50
+ */
51
+ getTelemetryLatencyChanges(projectId: string, callsign: string): Observable<number>;
44
52
  /** Per-service connectivity plus the aggregate verdict, polled. */
45
53
  getConnectivityChanges(projectId: string, callsign: string, opts?: RobotStatusOptions): Observable<RobotConnectivityStatus>;
46
54
  /** One-shot connectivity snapshot: resolves once every expected service is known, or after a timeout. */
@@ -1,8 +1,9 @@
1
1
  import { getConnectivityChanges } from './robot-status/connectivity';
2
2
  import { RobotHealth, RobotReadiness, RocosError, ServiceConnection, errorCodes, } from '../models';
3
3
  import { combineLatest, distinctUntilChanged, first, firstValueFrom, map, of, shareReplay, startWith, take, tap, timeout, } from 'rxjs';
4
- import { getReportedStatusChanges, getStatusContributorsChanges, getTelemetryLiveness, } from './robot-status/reportedStatus';
4
+ import { getReportedStatusChanges, getStatusContributorsChanges, getTelemetryLatencyChanges, getTelemetryLiveness, } from './robot-status/reportedStatus';
5
5
  import { BaseServiceAbstract } from './BaseServiceAbstract';
6
+ import { PlatFormTimeService } from './PlatformTimeService';
6
7
  import { RocosLogger } from '../logger/RocosLogger';
7
8
  import { RocosStore } from '../store/RocosStore';
8
9
  import { getRobotStatusColour } from '../helpers/getRobotStatusColour';
@@ -31,6 +32,7 @@ export class RobotStatusService extends BaseServiceAbstract {
31
32
  constructor(config) {
32
33
  super(config);
33
34
  this.logger = RocosLogger.getInstance(`RobotStatusService(${this.config.url})`);
35
+ this.platformTime = PlatFormTimeService.getInstance(RocosStore.getSDKInstance(this.config).getTimeSyncerService());
34
36
  }
35
37
  getStatus() {
36
38
  return true;
@@ -43,6 +45,15 @@ export class RobotStatusService extends BaseServiceAbstract {
43
45
  getStatusContributorsChanges(projectId, callsign) {
44
46
  return getStatusContributorsChanges(this.telemetryService, projectId, callsign);
45
47
  }
48
+ /**
49
+ * Telemetry latency in milliseconds — platform time minus when the agent created each liveness
50
+ * message (`robot/status`, or the legacy heartbeat). Emits once per message, and nothing while
51
+ * none arrive: pair it with the `telemetry-liveness` connectivity service to tell a stale value
52
+ * from a live one.
53
+ */
54
+ getTelemetryLatencyChanges(projectId, callsign) {
55
+ return getTelemetryLatencyChanges(this.telemetryService, projectId, callsign, () => this.platformTime.platformTime);
56
+ }
46
57
  /** Per-service connectivity plus the aggregate verdict, polled. */
47
58
  getConnectivityChanges(projectId, callsign, opts) {
48
59
  return getConnectivityChanges(this.connectivityDeps(projectId, callsign, opts), projectId, callsign, opts?.expectedServices, opts?.connectivityPollMs);
@@ -41,6 +41,18 @@ export declare const getReportedStatusChanges: (telemetry: TelemetryService, pro
41
41
  * error falls back to an empty breakdown rather than terminating the stream.
42
42
  */
43
43
  export declare const getStatusContributorsChanges: (telemetry: TelemetryService, projectId: string, callsign: string) => Observable<RobotStatusContributors>;
44
+ /**
45
+ * Emits the robot's telemetry latency in milliseconds, once per liveness message (from either the
46
+ * new `robot/status` topic or the legacy heartbeat — the same messages {@link getTelemetryLiveness}
47
+ * watches): `now()` minus the time the agent created the message.
48
+ *
49
+ * `now` should return platform time, so the measurement isn't skewed by the client's clock. Any
50
+ * remaining offset between the agent's clock and platform time feeds straight through, so a value
51
+ * can be slightly negative. Nothing is emitted while no messages arrive; pair this with
52
+ * {@link getTelemetryLiveness} to tell a stale value from a live one. A telemetry error completes
53
+ * the stream rather than erroring it.
54
+ */
55
+ export declare const getTelemetryLatencyChanges: (telemetry: TelemetryService, projectId: string, callsign: string, now: () => number) => Observable<number>;
44
56
  /**
45
57
  * Emits the `telemetry-liveness` connectivity signal: whether a heartbeat (from
46
58
  * either the new `robot/status` topic or the legacy heartbeat) has been received
@@ -1,4 +1,4 @@
1
- import { catchError, combineLatest, distinctUntilChanged, filter, interval, map, merge, of, scan, startWith, } from 'rxjs';
1
+ import { EMPTY, catchError, combineLatest, distinctUntilChanged, filter, interval, map, merge, of, scan, startWith, } from 'rxjs';
2
2
  import { RobotHealth, RobotReadiness, ServiceConnection, } from '../../models';
3
3
  /** The new agent topic carrying health + readiness (replaces the heartbeat). */
4
4
  export const ROBOT_STATUS_SOURCE = '/diagnostics/robot/status';
@@ -112,6 +112,22 @@ export const getStatusContributorsChanges = (telemetry, projectId, callsign) =>
112
112
  };
113
113
  }), startWith(EMPTY_CONTRIBUTORS), distinctUntilChanged((a, b) => JSON.stringify(a) === JSON.stringify(b)), catchError(() => of(EMPTY_CONTRIBUTORS)));
114
114
  };
115
+ /**
116
+ * Emits the robot's telemetry latency in milliseconds, once per liveness message (from either the
117
+ * new `robot/status` topic or the legacy heartbeat — the same messages {@link getTelemetryLiveness}
118
+ * watches): `now()` minus the time the agent created the message.
119
+ *
120
+ * `now` should return platform time, so the measurement isn't skewed by the client's clock. Any
121
+ * remaining offset between the agent's clock and platform time feeds straight through, so a value
122
+ * can be slightly negative. Nothing is emitted while no messages arrive; pair this with
123
+ * {@link getTelemetryLiveness} to tell a stale value from a live one. A telemetry error completes
124
+ * the stream rather than erroring it.
125
+ */
126
+ export const getTelemetryLatencyChanges = (telemetry, projectId, callsign, now) => {
127
+ return telemetry
128
+ .subscribe({ projectId, callsigns: [callsign], sources: [ROBOT_STATUS_SOURCE, LEGACY_HEARTBEAT_SOURCE] })
129
+ .pipe(map((message) => now() - message.createdAt.getTime()), catchError(() => EMPTY));
130
+ };
115
131
  /**
116
132
  * Emits the `telemetry-liveness` connectivity signal: whether a heartbeat (from
117
133
  * either the new `robot/status` topic or the legacy heartbeat) has been received
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dronedeploy/rocos-js-sdk",
3
- "version": "4.4.16-rc.1",
3
+ "version": "4.5.0",
4
4
  "description": "Javascript SDK for rocos",
5
5
  "main": "cjs/index.js",
6
6
  "module": "esm/index.js",