@dronedeploy/rocos-js-sdk 4.5.0 → 4.5.2
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/cjs/constants/api.d.ts +2 -0
- package/cjs/constants/api.js +4 -2
- package/cjs/models/maps/MapContent.d.ts +9 -0
- package/cjs/services/BaseServiceAbstract.d.ts +5 -0
- package/cjs/services/BaseServiceAbstract.js +9 -0
- package/cjs/services/MapService.d.ts +28 -2
- package/cjs/services/MapService.js +37 -0
- package/cjs/services/RobotStatusService.d.ts +22 -3
- package/cjs/services/RobotStatusService.js +79 -13
- package/cjs/services/index.d.ts +1 -0
- package/cjs/services/robot-status/connectivity.d.ts +19 -30
- package/cjs/services/robot-status/connectivity.js +16 -58
- package/cjs/services/robot-status/reportedStatus.d.ts +11 -4
- package/cjs/services/robot-status/reportedStatus.js +14 -9
- package/cjs/services/robot-status/sharedStreams.d.ts +28 -0
- package/cjs/services/robot-status/sharedStreams.js +52 -0
- package/esm/constants/api.d.ts +2 -0
- package/esm/constants/api.js +2 -0
- package/esm/models/maps/MapContent.d.ts +9 -0
- package/esm/services/BaseServiceAbstract.d.ts +5 -0
- package/esm/services/BaseServiceAbstract.js +9 -0
- package/esm/services/MapService.d.ts +28 -2
- package/esm/services/MapService.js +39 -2
- package/esm/services/RobotStatusService.d.ts +22 -3
- package/esm/services/RobotStatusService.js +82 -16
- package/esm/services/index.d.ts +1 -0
- package/esm/services/robot-status/connectivity.d.ts +19 -30
- package/esm/services/robot-status/connectivity.js +14 -56
- package/esm/services/robot-status/reportedStatus.d.ts +11 -4
- package/esm/services/robot-status/reportedStatus.js +12 -7
- package/esm/services/robot-status/sharedStreams.d.ts +28 -0
- package/esm/services/robot-status/sharedStreams.js +48 -0
- package/package.json +1 -1
package/cjs/constants/api.d.ts
CHANGED
|
@@ -129,6 +129,8 @@ export declare const API_GRAPHS_MAPS_DEPLOYED_URL = "https://{url}/graphs/projec
|
|
|
129
129
|
export declare const API_GRAPHS_MAPS_UNION_URL = "https://{url}/graphs/projects/{projectId}/maps/union";
|
|
130
130
|
export declare const API_GRAPHS_MAP_ID_URL = "https://{url}/graphs/projects/{projectId}/maps/{mapId}";
|
|
131
131
|
export declare const API_GRAPHS_MAP_CONTENT_URL = "https://{url}/graphs/projects/{projectId}/maps/{mapId}/content";
|
|
132
|
+
export declare const API_GRAPHS_MAP_EXTERNAL_DATA_UPLOAD_URL = "https://{url}/graphs/projects/{projectId}/maps/externaldata";
|
|
133
|
+
export declare const API_GRAPHS_MAP_EXTERNAL_DATA_URL = "https://{url}/graphs/projects/{projectId}/maps/externaldata/{hash}";
|
|
132
134
|
export declare const API_GRAPHS_MAP_METADATA_URL = "https://{url}/graphs/projects/{projectId}/maps/{mapId}/metadata";
|
|
133
135
|
export declare const API_GRAPHS_MAP_NODES_ADD_URL = "https://{url}/graphs/projects/{projectId}/maps/{mapId}/nodes/add";
|
|
134
136
|
export declare const API_GRAPHS_MAP_NODES_ADD_TRANSFORMABLE_URL = "https://{url}/graphs/projects/{projectId}/maps/{mapId}/nodes/add/transformable";
|
package/cjs/constants/api.js
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.API_PROJECT_ROBOT_EVENT_URL = exports.API_PROJECT_ROBOT_REGISTER_URL = exports.API_PROJECT_ROBOT_DEFINITION_URL = exports.API_PROJECT_ROBOT_ATTRIBUTES_URL = exports.API_PROJECT_ROBOT_ID_URL = exports.API_ACCOUNT_ROBOT_URL = exports.API_PROJECT_ROBOT_URL = exports.API_PROJECT_MAPPED_ASSET_PATH_URL = exports.API_PROJECT_MAPPED_ASSETS_PATH_URL = exports.API_PROJECT_MISSION_ASSET_PATH_URL = exports.API_PROJECT_MISSION_ASSETS_PATH_URL = exports.API_PROJECT_FLOW_ASSET_PATH_URL = exports.API_PROJECT_ROBOT_ASSET_PATH_URL = exports.API_PROJECT_ASSET_INTEGRATION_PATH_URL = exports.API_PROJECT_ASSET_INTEGRATIONS_PATH_URL = exports.API_PROJECT_ASSET_INTEGRATION_PROVIDERS_PATH_URL = exports.API_PROJECT_ASSET_PROFILES_SYNC_DEFINITION_PATH_URL = exports.API_PROJECT_ASSET_ROBOTS_SYNC_DEFINITION_PATH_URL = exports.API_PROJECT_ASSET_PATH_URL = exports.API_PROJECT_ASSET_URL = exports.API_PROJECT_USERS_URL = exports.API_PROJECT_ID_URL = exports.API_PROJECT_URL = exports.API_ACCOUNT_EXTERNAL_PROJECTS_URL = exports.API_ACCOUNT_PROJECT_APPLICATION_ID_URL = exports.API_ACCOUNT_PROJECT_APPLICATION_URL = exports.API_ACCOUNT_PROJECT_USER_ID_URL = exports.API_ACCOUNT_PROJECT_USER_URL = exports.API_ACCOUNT_PROJECT_ID_URL = exports.API_ACCOUNT_PROJECT_URL = exports.API_SERVER_TIME_URL = exports.API_ACCOUNT_SETTINGS_URL = exports.API_AUTH_USER_ACCOUNT_USER_ID_URL = exports.API_AUTH_USER_ACCOUNT_USER_URL = exports.API_ACCOUNT_ACTIVATE_URL = exports.API_ACCOUNT_ID_URL = exports.API_ACCOUNT_URL = exports.API_USER_PAT_TOKEN_URL = exports.API_USER_PAT_URL = exports.API_USER_VERIFY_EMAIL_URL = exports.API_USER_INVITATION_CHECK_URL = exports.API_USER_INVITATION_ACCEPT_URL = exports.API_USER_INVITATION_URL = exports.API_USER_PASSWORD_FORGOT_URL = exports.API_OTP_AUTH_URL = exports.API_OTP_URL = exports.API_USER_TOKEN_URL = exports.API_USER_URL = exports.API_ADMIN_USER_INVITATION_URL = exports.API_APPLICATION_AUTH_URL = void 0;
|
|
4
4
|
exports.API_PROJECT_STREAM_URL = exports.API_PROJECT_GROUP_TYPE_OWNER_OVERRIDE_URL = exports.API_PROJECT_GROUP_TYPE_OWNER_ID_URL = exports.API_PROJECT_GROUP_TYPE_VERSION_URL = exports.API_PROJECT_GROUP_TYPE_CONFIG_URL = exports.API_PROJECT_GROUP_TYPE_PUBLISH_URL = exports.API_PROJECT_GROUP_TYPE_ID_URL = exports.API_PROJECT_GROUP_TYPE_URL = exports.API_PROJECT_ENVIRONMENT_URL = exports.API_PROJECT_DEFINITION_LIBRARY = exports.API_PROJECT_DEFINITION_IMPORT_LIBRARY = exports.API_PROJECT_DEFINITION_IMPORT = exports.API_PROJECT_DEFINITION_EXPORT = exports.API_PROJECT_DEFINITION_GAMEPAD_URL = exports.API_PROJECT_DEFINITION_TRIGGER_URL = exports.API_PROJECT_DEFINITION_BUTTON_URL = exports.API_PROJECT_DEFINITION_ACTION_URL = exports.API_PROJECT_DEFINITION_EVENT_URL = exports.API_PROJECT_DEFINITION_COMMAND2_URL = exports.API_PROJECT_DEFINITION_COMMAND_URL = exports.API_PROJECT_DEFINITION_AGENT_URL = exports.API_PROJECT_DEFINITION_SETTING_URL = exports.API_PROJECT_DEFINITION_BLOB_URL = exports.API_PROJECT_DEFINITION_DASHBOARD_URL = exports.API_PROJECT_DEFINITION_COPY_URL = exports.API_PROJECT_DEFINITION_STREAM_URL = exports.API_PROJECT_DEFINITION_ID_URL = exports.API_PROJECT_DEFINITION_URL = exports.API_PROJECT_VROBOT_DEPLOY_URL = exports.API_PROJECT_VROBOT_DETAILS_URL = exports.API_PROJECT_COLLECTION_DOCS_URL = exports.API_PROJECT_COLLECTION_ID_URL = exports.API_PROJECT_DASHBOARD_CUSTOM_WIDGET_URL = exports.API_PROJECT_DASHBOARD_WIDGET_URL = exports.API_PROJECT_DASHBOARD_ID_URL = exports.API_PROJECT_DASHBOARD_URL = exports.API_PROJECT_OPERATION_ID_URL = exports.API_PROJECT_OPERATION_URL = exports.API_PROJECT_ROBOT_CONFIGS_CONNECTION_URL = exports.API_PROJECT_ROBOT_CONFIGS_CONNECTIONS_URL = exports.API_SERVICE_CONNECTION_URL = exports.API_SERVICE_CONNECTIONS_URL = exports.API_PROJECT_ROBOT_GAMEPAD_URL = exports.API_PROJECT_ROBOT_TRIGGER_URL = exports.API_PROJECT_ROBOT_BUTTON_URL = exports.API_PROJECT_ROBOT_COMMAND2_URL = exports.API_PROJECT_ROBOT_COMMAND_URL = exports.API_PROJECT_ROBOT_AGENT_URL = exports.API_PROJECT_ROBOT_SETTING_URL = exports.API_PROJECT_ROBOT_EVENT_HISTORY_URL = void 0;
|
|
5
|
-
exports.
|
|
6
|
-
exports.API_PROJECT_ROBOT_TAG_URL = exports.API_PROJECT_PROFILE_TAG_URL = exports.API_PROJECT_PROFILE_TAGS_URL = exports.API_PROJECT_TAG_ROBOTS_URL = exports.API_PROJECT_ROBOT_TAGS_URL = exports.API_DEVICE_CREDENTIALS_AUTH_URL = exports.API_DEVICE_CREDENTIALS_URL = exports.API_LINKED_PROJECT_URL = exports.API_PROJECT_WORKFLOW_IMPORT_URL = exports.API_PROJECT_WORKFLOW_EXPORT_URL = exports.API_PROJECT_WORKFLOW_AFFECTED_URL = exports.API_PROJECT_ROBOT_DEPLOYED_WORKFLOW_URL = exports.API_PROJECT_PROFILE_DEPLOYED_WORKFLOW_URL = exports.API_PROJECT_ROBOT_NO_PROFILE_DEPLOYMENTS_URL = exports.API_PROJECT_PROFILE_DEPLOYMENTS_URL = exports.API_PROJECT_ROBOT_DEPLOYMENTS_URL = exports.API_PROJECT_WORKFLOW_ASSET_ID_URL = exports.API_PROJECT_WORKFLOW_ASSET_URL = exports.API_PROJECT_WORKFLOW_ID_URL = exports.API_PROJECT_WORKFLOW_URL = exports.API_GRAPHS_TARGET_MEDIA_URL = exports.API_GRAPHS_ASSETS_URL = exports.API_GRAPHS_ASSETS_UPLOAD_URL = exports.API_GRAPHS_TARGETS_URL = exports.API_GRAPHS_TARGET_UPLOAD_URL = void 0;
|
|
5
|
+
exports.API_GRAPHS_PANORAMA_OBSERVATIONS_URL = exports.API_GRAPHS_PANORAMA = exports.API_GRAPHS_PANORAMAS_URL = exports.API_GRAPHS_MAPS_GEOJSON_URL = exports.API_GRAPHS_MAPS_DEPLOY_URL = exports.API_GRAPHS_MAPS_COPY_URL = exports.API_GRAPHS_MAP_PATH_APPEND_TRANSFORMABLE_URL = exports.API_GRAPHS_MAP_PATH_APPEND_URL = exports.API_GRAPHS_MAP_PATH_URL = exports.API_GRAPHS_MAP_PATHS_URL = exports.API_GRAPHS_MAP_EDGE_URL = exports.API_GRAPHS_MAP_EDGES_ADD_TRANSFORM_URL = exports.API_GRAPHS_MAP_EDGES_ADD_URL = exports.API_GRAPHS_MAP_NODE_URL = exports.API_GRAPHS_MAP_NODES_ADD_TRANSFORMABLE_URL = exports.API_GRAPHS_MAP_NODES_ADD_URL = exports.API_GRAPHS_MAP_METADATA_URL = exports.API_GRAPHS_MAP_EXTERNAL_DATA_URL = exports.API_GRAPHS_MAP_EXTERNAL_DATA_UPLOAD_URL = exports.API_GRAPHS_MAP_CONTENT_URL = exports.API_GRAPHS_MAP_ID_URL = exports.API_GRAPHS_MAPS_UNION_URL = exports.API_GRAPHS_MAPS_DEPLOYED_URL = exports.API_GRAPHS_MAPS_NEW_URL = exports.API_GRAPHS_MAPS_URL = exports.API_DD_INTEGRATION_LEVELS_URL = exports.API_DD_INTEGRATION_LOCATIONS_URL = exports.API_DD_INTEGRATION_ISSUES_URL = exports.API_DD_INTEGRATION_OVERLAYS_URL = exports.API_DD_INTEGRATION_PLAN_BY_ID_URL = exports.API_DD_INTEGRATION_PLANS_URL = exports.API_SPOTTY_URL = exports.API_PROJECT_SCHEDULES_URL = exports.API_SOURCE_ID_URL = exports.API_SOURCE_URL = exports.API_SOURCE_SCHEMA_URL = exports.API_TEMPLATE_EXPORTER_URL = exports.API_TEMPLATE_PROVISION_ID_URL = exports.API_TEMPLATE_PROVISION_URL = exports.API_TEMPLATE_DEPLOY_URL = exports.API_PROJECT_PROFILE_DASHBOARD_CUSTOM_WIDGET_URL = exports.API_PROJECT_PROFILE_DASHBOARD_ID_URL = exports.API_PROJECT_PROFILE_DASHBOARD_URL = exports.API_PROJECT_CALLSIGN_STREAM_URL = exports.API_PROJECT_ROBOT_DASHBOARD_CUSTOM_WIDGET_URL = exports.API_PROJECT_ROBOT_DASHBOARD_ID_URL = exports.API_PROJECT_ROBOT_DASHBOARD_URL = exports.API_PROJECT_STREAM_CALLSIGN_URL = exports.API_PROJECT_STREAM_DATA_URL = exports.API_PROJECT_STREAM_ID_URL = void 0;
|
|
6
|
+
exports.API_PROJECT_ROBOT_TAG_URL = exports.API_PROJECT_PROFILE_TAG_URL = exports.API_PROJECT_PROFILE_TAGS_URL = exports.API_PROJECT_TAG_ROBOTS_URL = exports.API_PROJECT_ROBOT_TAGS_URL = exports.API_DEVICE_CREDENTIALS_AUTH_URL = exports.API_DEVICE_CREDENTIALS_URL = exports.API_LINKED_PROJECT_URL = exports.API_PROJECT_WORKFLOW_IMPORT_URL = exports.API_PROJECT_WORKFLOW_EXPORT_URL = exports.API_PROJECT_WORKFLOW_AFFECTED_URL = exports.API_PROJECT_ROBOT_DEPLOYED_WORKFLOW_URL = exports.API_PROJECT_PROFILE_DEPLOYED_WORKFLOW_URL = exports.API_PROJECT_ROBOT_NO_PROFILE_DEPLOYMENTS_URL = exports.API_PROJECT_PROFILE_DEPLOYMENTS_URL = exports.API_PROJECT_ROBOT_DEPLOYMENTS_URL = exports.API_PROJECT_WORKFLOW_ASSET_ID_URL = exports.API_PROJECT_WORKFLOW_ASSET_URL = exports.API_PROJECT_WORKFLOW_ID_URL = exports.API_PROJECT_WORKFLOW_URL = exports.API_GRAPHS_TARGET_MEDIA_URL = exports.API_GRAPHS_ASSETS_URL = exports.API_GRAPHS_ASSETS_UPLOAD_URL = exports.API_GRAPHS_TARGETS_URL = exports.API_GRAPHS_TARGET_UPLOAD_URL = exports.API_GRAPHS_OBSERVATION_KEYS_URL = exports.API_GRAPHS_OBSERVATIONS_URL = void 0;
|
|
7
7
|
exports.API_APPLICATION_AUTH_URL = 'https://{url}/applications/auth';
|
|
8
8
|
exports.API_ADMIN_USER_INVITATION_URL = 'https://{url}/admin/users/invitations';
|
|
9
9
|
exports.API_USER_URL = 'https://{url}/users';
|
|
@@ -137,6 +137,8 @@ exports.API_GRAPHS_MAPS_DEPLOYED_URL = 'https://{url}/graphs/projects/{projectId
|
|
|
137
137
|
exports.API_GRAPHS_MAPS_UNION_URL = 'https://{url}/graphs/projects/{projectId}/maps/union';
|
|
138
138
|
exports.API_GRAPHS_MAP_ID_URL = 'https://{url}/graphs/projects/{projectId}/maps/{mapId}';
|
|
139
139
|
exports.API_GRAPHS_MAP_CONTENT_URL = 'https://{url}/graphs/projects/{projectId}/maps/{mapId}/content';
|
|
140
|
+
exports.API_GRAPHS_MAP_EXTERNAL_DATA_UPLOAD_URL = 'https://{url}/graphs/projects/{projectId}/maps/externaldata';
|
|
141
|
+
exports.API_GRAPHS_MAP_EXTERNAL_DATA_URL = 'https://{url}/graphs/projects/{projectId}/maps/externaldata/{hash}';
|
|
140
142
|
exports.API_GRAPHS_MAP_METADATA_URL = 'https://{url}/graphs/projects/{projectId}/maps/{mapId}/metadata';
|
|
141
143
|
exports.API_GRAPHS_MAP_NODES_ADD_URL = 'https://{url}/graphs/projects/{projectId}/maps/{mapId}/nodes/add';
|
|
142
144
|
exports.API_GRAPHS_MAP_NODES_ADD_TRANSFORMABLE_URL = 'https://{url}/graphs/projects/{projectId}/maps/{mapId}/nodes/add/transformable';
|
|
@@ -24,3 +24,12 @@ export interface MapContentEdge {
|
|
|
24
24
|
data: Record<string, unknown>;
|
|
25
25
|
externalData?: Record<string, unknown>;
|
|
26
26
|
}
|
|
27
|
+
/** What `PUT /graphs/projects/{projectId}/maps/externaldata` returns for stored bytes. */
|
|
28
|
+
export interface ExternalDataUploadResponse {
|
|
29
|
+
/** sha256 of the bytes: the `hash` a node's or edge's `externalData` entry names. */
|
|
30
|
+
hash: string;
|
|
31
|
+
/** How many bytes were stored. */
|
|
32
|
+
bytes: number;
|
|
33
|
+
/** The media type they were stored with. */
|
|
34
|
+
contentType: string;
|
|
35
|
+
}
|
|
@@ -16,6 +16,11 @@ interface RequestConfig {
|
|
|
16
16
|
*/
|
|
17
17
|
responseType?: ResponseType;
|
|
18
18
|
}
|
|
19
|
+
/**
|
|
20
|
+
* Bytes to send as a request body verbatim, rather than JSON-encoded. A view must sit on a plain
|
|
21
|
+
* ArrayBuffer, as fetch requires.
|
|
22
|
+
*/
|
|
23
|
+
export type BinaryPayload = Blob | ArrayBuffer | ArrayBufferView<ArrayBuffer>;
|
|
19
24
|
export declare abstract class BaseServiceAbstract {
|
|
20
25
|
protected config: IRocosSDKConfig;
|
|
21
26
|
protected logger: Logger;
|
|
@@ -4,6 +4,11 @@ exports.BaseServiceAbstract = void 0;
|
|
|
4
4
|
const models_1 = require("../models");
|
|
5
5
|
const helpers_1 = require("../helpers");
|
|
6
6
|
const RocosStore_1 = require("../store/RocosStore");
|
|
7
|
+
const isBinaryPayload = (payload) => {
|
|
8
|
+
if (typeof Blob !== 'undefined' && payload instanceof Blob)
|
|
9
|
+
return true;
|
|
10
|
+
return payload instanceof ArrayBuffer || ArrayBuffer.isView(payload);
|
|
11
|
+
};
|
|
7
12
|
class BaseServiceAbstract {
|
|
8
13
|
constructor(config) {
|
|
9
14
|
this.config = config;
|
|
@@ -40,6 +45,10 @@ class BaseServiceAbstract {
|
|
|
40
45
|
if (typeof FormData !== 'undefined' && payload instanceof FormData) {
|
|
41
46
|
requestConfig.body = payload;
|
|
42
47
|
}
|
|
48
|
+
else if (isBinaryPayload(payload)) {
|
|
49
|
+
// Raw bytes go up as-is; the caller names their media type in config.headers.
|
|
50
|
+
requestConfig.body = payload;
|
|
51
|
+
}
|
|
43
52
|
else if (payload) {
|
|
44
53
|
requestConfig.body = JSON.stringify(payload);
|
|
45
54
|
requestConfig.headers = { ...requestConfig.headers, 'Content-Type': 'application/json' };
|
|
@@ -2,8 +2,8 @@ import { AddEdgeRequest, AddEdgeResponse, AddTransformEdgeRequest } from '../mod
|
|
|
2
2
|
import { AddNodeRequest, AddNodeResponse, AddTransformableNodeRequest } from '../models/maps/MapNode';
|
|
3
3
|
import { AddPanoramaRequest, AddPanoramaResponse, CreateObservation, Observation } from '../models/maps/Panorama';
|
|
4
4
|
import { AppendPathPointsResponse, AppendToPathRequest, AppendTransformablePointsRequest, ListPathsFilter, MapPath, ReplacePathRequest } from '../models/maps/MapPath';
|
|
5
|
-
import { Asset, IBaseService, IRocosSDKConfig, Map, MapContent, RocosError } from '../models';
|
|
6
|
-
import { BaseServiceAbstract } from './BaseServiceAbstract';
|
|
5
|
+
import { Asset, ExternalDataUploadResponse, IBaseService, IRocosSDKConfig, Map, MapContent, RocosError } from '../models';
|
|
6
|
+
import { BaseServiceAbstract, BinaryPayload } from './BaseServiceAbstract';
|
|
7
7
|
/**
|
|
8
8
|
* Maps service for managing robot maps in the cloud and on robots
|
|
9
9
|
*/
|
|
@@ -105,6 +105,32 @@ export declare class MapService extends BaseServiceAbstract implements IBaseServ
|
|
|
105
105
|
* @param content Canonical map content to write
|
|
106
106
|
*/
|
|
107
107
|
updateContent(projectId: string, mapId: string, content: MapContent): Promise<void>;
|
|
108
|
+
/**
|
|
109
|
+
* Downloads the bytes behind a map node's or edge's `externalData` entry.
|
|
110
|
+
*
|
|
111
|
+
* The entry names the bytes by `hash`; giraffe answers with a redirect to a
|
|
112
|
+
* signed download URL, which `fetch` follows. The returned blob carries the
|
|
113
|
+
* content type the bytes were stored with. An entry whose `encoding` is
|
|
114
|
+
* `b64` holds base64 text, which the caller decodes.
|
|
115
|
+
*
|
|
116
|
+
* @param projectId Project ID
|
|
117
|
+
* @param hash The entry's `hash`
|
|
118
|
+
*/
|
|
119
|
+
getExternalData(projectId: string, hash: string): Promise<Blob>;
|
|
120
|
+
/**
|
|
121
|
+
* Stores bytes as map external data, for a node's or edge's `externalData`
|
|
122
|
+
* entry to name by the returned `hash`.
|
|
123
|
+
*
|
|
124
|
+
* Giraffe hashes the bytes (sha256) and keeps them in the project's map-asset
|
|
125
|
+
* store under that hash with the given media type, which is what
|
|
126
|
+
* {@link getExternalData} later serves. Storing the same bytes twice is
|
|
127
|
+
* harmless. The server caps one item at 64 MiB.
|
|
128
|
+
*
|
|
129
|
+
* @param projectId Project ID
|
|
130
|
+
* @param data The bytes to store
|
|
131
|
+
* @param contentType Their media type; `application/octet-stream` when omitted
|
|
132
|
+
*/
|
|
133
|
+
putExternalData(projectId: string, data: BinaryPayload, contentType?: string): Promise<ExternalDataUploadResponse>;
|
|
108
134
|
/**
|
|
109
135
|
* Begins uploading a map from the agent
|
|
110
136
|
*
|
|
@@ -154,6 +154,43 @@ class MapService extends BaseServiceAbstract_1.BaseServiceAbstract {
|
|
|
154
154
|
mapId,
|
|
155
155
|
}, this.config.insecure), content, 'Failed to update map content.');
|
|
156
156
|
}
|
|
157
|
+
/**
|
|
158
|
+
* Downloads the bytes behind a map node's or edge's `externalData` entry.
|
|
159
|
+
*
|
|
160
|
+
* The entry names the bytes by `hash`; giraffe answers with a redirect to a
|
|
161
|
+
* signed download URL, which `fetch` follows. The returned blob carries the
|
|
162
|
+
* content type the bytes were stored with. An entry whose `encoding` is
|
|
163
|
+
* `b64` holds base64 text, which the caller decodes.
|
|
164
|
+
*
|
|
165
|
+
* @param projectId Project ID
|
|
166
|
+
* @param hash The entry's `hash`
|
|
167
|
+
*/
|
|
168
|
+
async getExternalData(projectId, hash) {
|
|
169
|
+
return this.callGet((0, formatServiceUrl_1.formatServiceUrl)(api_1.API_GRAPHS_MAP_EXTERNAL_DATA_URL, {
|
|
170
|
+
url: this.config.url,
|
|
171
|
+
projectId,
|
|
172
|
+
hash: encodeURIComponent(hash),
|
|
173
|
+
}, this.config.insecure), 'Failed to get map external data.', undefined, { responseType: 'blob' });
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* Stores bytes as map external data, for a node's or edge's `externalData`
|
|
177
|
+
* entry to name by the returned `hash`.
|
|
178
|
+
*
|
|
179
|
+
* Giraffe hashes the bytes (sha256) and keeps them in the project's map-asset
|
|
180
|
+
* store under that hash with the given media type, which is what
|
|
181
|
+
* {@link getExternalData} later serves. Storing the same bytes twice is
|
|
182
|
+
* harmless. The server caps one item at 64 MiB.
|
|
183
|
+
*
|
|
184
|
+
* @param projectId Project ID
|
|
185
|
+
* @param data The bytes to store
|
|
186
|
+
* @param contentType Their media type; `application/octet-stream` when omitted
|
|
187
|
+
*/
|
|
188
|
+
async putExternalData(projectId, data, contentType = 'application/octet-stream') {
|
|
189
|
+
return this.callPut((0, formatServiceUrl_1.formatServiceUrl)(api_1.API_GRAPHS_MAP_EXTERNAL_DATA_UPLOAD_URL, {
|
|
190
|
+
url: this.config.url,
|
|
191
|
+
projectId,
|
|
192
|
+
}, this.config.insecure), data, 'Failed to store map external data.', { headers: { 'Content-Type': contentType } });
|
|
193
|
+
}
|
|
157
194
|
/**
|
|
158
195
|
* Begins uploading a map from the agent
|
|
159
196
|
*
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { ReportedRobotStatus } from './robot-status/reportedStatus';
|
|
1
2
|
import { IBaseService, IRocosSDKConfig, RobotConnectivityStatus, RobotStatus, RobotStatusContributors, RocosError, ServiceConnection } from '../models';
|
|
2
3
|
import { Observable } from 'rxjs';
|
|
3
|
-
import { ReportedRobotStatus } from './robot-status/reportedStatus';
|
|
4
4
|
import { BaseServiceAbstract } from './BaseServiceAbstract';
|
|
5
5
|
/** Per-call tuning for the robot status observables. */
|
|
6
6
|
export interface RobotStatusOptions {
|
|
@@ -49,7 +49,11 @@ export declare class RobotStatusService extends BaseServiceAbstract implements I
|
|
|
49
49
|
* from a live one.
|
|
50
50
|
*/
|
|
51
51
|
getTelemetryLatencyChanges(projectId: string, callsign: string): Observable<number>;
|
|
52
|
-
/**
|
|
52
|
+
/**
|
|
53
|
+
* Per-service connectivity plus the aggregate verdict, for `opts.expectedServices` plus any
|
|
54
|
+
* `opts.extraServices` (folded in on equal footing). HTTP services are read from their project's
|
|
55
|
+
* shared bulk poll; an unrecognised service id resolves to `UNKNOWN`.
|
|
56
|
+
*/
|
|
53
57
|
getConnectivityChanges(projectId: string, callsign: string, opts?: RobotStatusOptions): Observable<RobotConnectivityStatus>;
|
|
54
58
|
/** One-shot connectivity snapshot: resolves once every expected service is known, or after a timeout. */
|
|
55
59
|
getConnectivity(projectId: string, callsign: string, opts?: RobotStatusOptions): Promise<RobotConnectivityStatus>;
|
|
@@ -60,5 +64,20 @@ export declare class RobotStatusService extends BaseServiceAbstract implements I
|
|
|
60
64
|
getRobotStatusChanges(projectId: string, callsign: string, opts?: RobotStatusOptions): Observable<RobotStatus>;
|
|
61
65
|
protected getError(e: Error): RocosError;
|
|
62
66
|
private get telemetryService();
|
|
63
|
-
|
|
67
|
+
/**
|
|
68
|
+
* Shared streams are keyed by this, so equivalent SDK configurations (which `RocosStore` already
|
|
69
|
+
* treats as one SDK) share them, and different ones never do.
|
|
70
|
+
*/
|
|
71
|
+
private get configKey();
|
|
72
|
+
/** Telemetry with one pooled subscription per robot and topic, however many status streams use it. */
|
|
73
|
+
private get sharedTelemetry();
|
|
74
|
+
private getTelemetryLiveness;
|
|
75
|
+
/** One service's connection for a callsign. Built-in services win over an injected one of the same id. */
|
|
76
|
+
private getServiceConnection;
|
|
77
|
+
/**
|
|
78
|
+
* A service's bulk (per-project) `connections` endpoint, polled every `pollMs`. One poll per project,
|
|
79
|
+
* service and interval is shared by every callsign and subscriber. A failed poll emits `undefined`
|
|
80
|
+
* rather than erroring, so one bad poll doesn't end the stream.
|
|
81
|
+
*/
|
|
82
|
+
private getProjectConnections;
|
|
64
83
|
}
|
|
@@ -2,14 +2,16 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.RobotStatusService = void 0;
|
|
4
4
|
const connectivity_1 = require("./robot-status/connectivity");
|
|
5
|
+
const reportedStatus_1 = require("./robot-status/reportedStatus");
|
|
5
6
|
const models_1 = require("../models");
|
|
6
7
|
const rxjs_1 = require("rxjs");
|
|
7
|
-
const reportedStatus_1 = require("./robot-status/reportedStatus");
|
|
8
8
|
const BaseServiceAbstract_1 = require("./BaseServiceAbstract");
|
|
9
9
|
const PlatformTimeService_1 = require("./PlatformTimeService");
|
|
10
10
|
const RocosLogger_1 = require("../logger/RocosLogger");
|
|
11
11
|
const RocosStore_1 = require("../store/RocosStore");
|
|
12
12
|
const getRobotStatusColour_1 = require("../helpers/getRobotStatusColour");
|
|
13
|
+
const getUniqueConfigKey_1 = require("../helpers/getUniqueConfigKey");
|
|
14
|
+
const sharedStreams_1 = require("./robot-status/sharedStreams");
|
|
13
15
|
/** Upper bound on how long the one-shot {@link RobotStatusService.getConnectivity} waits to settle. */
|
|
14
16
|
const ONE_SHOT_TIMEOUT_MS = 10000;
|
|
15
17
|
const isKnown = (status) => {
|
|
@@ -42,11 +44,11 @@ class RobotStatusService extends BaseServiceAbstract_1.BaseServiceAbstract {
|
|
|
42
44
|
}
|
|
43
45
|
/** Health + readiness as reported by the robot (new topic, legacy heartbeat fallback). */
|
|
44
46
|
getReportedStatusChanges(projectId, callsign) {
|
|
45
|
-
return (0, reportedStatus_1.getReportedStatusChanges)(this.
|
|
47
|
+
return sharedStreams_1.sharedStreamPool.get(['reported-status', this.configKey, projectId, callsign], () => (0, reportedStatus_1.getReportedStatusChanges)(this.sharedTelemetry, projectId, callsign), { replay: true });
|
|
46
48
|
}
|
|
47
49
|
/** Per-contributor breakdown behind the reported health and readiness, with the reason for each. */
|
|
48
50
|
getStatusContributorsChanges(projectId, callsign) {
|
|
49
|
-
return (0, reportedStatus_1.getStatusContributorsChanges)(this.
|
|
51
|
+
return sharedStreams_1.sharedStreamPool.get(['status-contributors', this.configKey, projectId, callsign], () => (0, reportedStatus_1.getStatusContributorsChanges)(this.sharedTelemetry, projectId, callsign), { replay: true });
|
|
50
52
|
}
|
|
51
53
|
/**
|
|
52
54
|
* Telemetry latency in milliseconds — platform time minus when the agent created each liveness
|
|
@@ -55,11 +57,34 @@ class RobotStatusService extends BaseServiceAbstract_1.BaseServiceAbstract {
|
|
|
55
57
|
* from a live one.
|
|
56
58
|
*/
|
|
57
59
|
getTelemetryLatencyChanges(projectId, callsign) {
|
|
58
|
-
return (0, reportedStatus_1.getTelemetryLatencyChanges)(this.
|
|
60
|
+
return (0, reportedStatus_1.getTelemetryLatencyChanges)(this.sharedTelemetry, projectId, callsign, () => this.platformTime.platformTime);
|
|
59
61
|
}
|
|
60
|
-
/**
|
|
62
|
+
/**
|
|
63
|
+
* Per-service connectivity plus the aggregate verdict, for `opts.expectedServices` plus any
|
|
64
|
+
* `opts.extraServices` (folded in on equal footing). HTTP services are read from their project's
|
|
65
|
+
* shared bulk poll; an unrecognised service id resolves to `UNKNOWN`.
|
|
66
|
+
*/
|
|
61
67
|
getConnectivityChanges(projectId, callsign, opts) {
|
|
62
|
-
|
|
68
|
+
const expectedServices = opts?.expectedServices ?? connectivity_1.DEFAULT_EXPECTED_SERVICES;
|
|
69
|
+
const extraServices = opts?.extraServices ?? {};
|
|
70
|
+
const serviceIds = [
|
|
71
|
+
...expectedServices,
|
|
72
|
+
...Object.keys(extraServices).filter((id) => !expectedServices.includes(id)),
|
|
73
|
+
];
|
|
74
|
+
// combineLatest([]) completes without emitting; emit an explicit empty/offline status instead.
|
|
75
|
+
if (serviceIds.length === 0) {
|
|
76
|
+
return (0, rxjs_1.of)({ overall: models_1.RobotConnectivity.OFFLINE, services: {} });
|
|
77
|
+
}
|
|
78
|
+
const pollMs = (0, connectivity_1.clampPollInterval)(opts?.connectivityPollMs ?? connectivity_1.DEFAULT_CONNECTIVITY_POLL_MS);
|
|
79
|
+
const perService = serviceIds.map((serviceId) => {
|
|
80
|
+
return this.getServiceConnection(projectId, callsign, serviceId, pollMs, opts).pipe((0, rxjs_1.startWith)(models_1.ServiceConnection.UNKNOWN), (0, rxjs_1.map)((connection) => ({ serviceId, connection })));
|
|
81
|
+
});
|
|
82
|
+
return (0, rxjs_1.combineLatest)(perService).pipe((0, rxjs_1.map)((entries) => {
|
|
83
|
+
const services = {};
|
|
84
|
+
for (const { serviceId, connection } of entries)
|
|
85
|
+
services[serviceId] = connection;
|
|
86
|
+
return { overall: (0, connectivity_1.aggregateConnectivity)(services), services };
|
|
87
|
+
}), (0, rxjs_1.distinctUntilChanged)(connectivity_1.connectivityEquals));
|
|
63
88
|
}
|
|
64
89
|
/** One-shot connectivity snapshot: resolves once every expected service is known, or after a timeout. */
|
|
65
90
|
getConnectivity(projectId, callsign, opts) {
|
|
@@ -95,16 +120,57 @@ class RobotStatusService extends BaseServiceAbstract_1.BaseServiceAbstract {
|
|
|
95
120
|
get telemetryService() {
|
|
96
121
|
return RocosStore_1.RocosStore.getSDKInstance(this.config).getTelemetryService();
|
|
97
122
|
}
|
|
98
|
-
|
|
123
|
+
/**
|
|
124
|
+
* Shared streams are keyed by this, so equivalent SDK configurations (which `RocosStore` already
|
|
125
|
+
* treats as one SDK) share them, and different ones never do.
|
|
126
|
+
*/
|
|
127
|
+
get configKey() {
|
|
128
|
+
return (0, getUniqueConfigKey_1.getUniqueConfigKey)(this.config);
|
|
129
|
+
}
|
|
130
|
+
/** Telemetry with one pooled subscription per robot and topic, however many status streams use it. */
|
|
131
|
+
get sharedTelemetry() {
|
|
99
132
|
return {
|
|
100
|
-
|
|
101
|
-
return
|
|
133
|
+
subscribe: (params) => {
|
|
134
|
+
return sharedStreams_1.sharedStreamPool.get(['telemetry', this.configKey, params.projectId, params.callsigns, params.sources], () => this.telemetryService.subscribe(params),
|
|
135
|
+
// Raw messages are events: replaying one to a late subscriber would read as a fresh message.
|
|
136
|
+
{ replay: false });
|
|
102
137
|
},
|
|
103
|
-
baseUrl: this.config.url,
|
|
104
|
-
insecure: this.config.insecure,
|
|
105
|
-
telemetryLiveness$: (0, reportedStatus_1.getTelemetryLiveness)(this.telemetryService, projectId, callsign, opts?.heartbeatTimeoutMs),
|
|
106
|
-
extraServices: opts?.extraServices,
|
|
107
138
|
};
|
|
108
139
|
}
|
|
140
|
+
getTelemetryLiveness(projectId, callsign, heartbeatTimeoutMs = reportedStatus_1.DEFAULT_HEARTBEAT_TIMEOUT_MS) {
|
|
141
|
+
// Key on the resolved timeout, so omitting it shares a stream with passing the default explicitly.
|
|
142
|
+
return sharedStreams_1.sharedStreamPool.get(['telemetry-liveness', this.configKey, projectId, callsign, heartbeatTimeoutMs], () => (0, reportedStatus_1.getTelemetryLiveness)(this.sharedTelemetry, projectId, callsign, heartbeatTimeoutMs), { replay: true });
|
|
143
|
+
}
|
|
144
|
+
/** One service's connection for a callsign. Built-in services win over an injected one of the same id. */
|
|
145
|
+
getServiceConnection(projectId, callsign, serviceId, pollMs, opts) {
|
|
146
|
+
if (serviceId === connectivity_1.TELEMETRY_LIVENESS_SERVICE) {
|
|
147
|
+
return this.getTelemetryLiveness(projectId, callsign, opts?.heartbeatTimeoutMs);
|
|
148
|
+
}
|
|
149
|
+
if (Object.prototype.hasOwnProperty.call(connectivity_1.CONNECTION_SERVICE_PREFIXES, serviceId)) {
|
|
150
|
+
return this.getProjectConnections(projectId, serviceId, pollMs).pipe((0, rxjs_1.map)((poll) => (0, connectivity_1.getCallsignConnection)(poll, callsign)), (0, rxjs_1.distinctUntilChanged)());
|
|
151
|
+
}
|
|
152
|
+
const extraServices = opts?.extraServices;
|
|
153
|
+
if (extraServices && Object.prototype.hasOwnProperty.call(extraServices, serviceId)) {
|
|
154
|
+
// Contain an injected observable's errors as UNKNOWN, mirroring the built-in sources, so a
|
|
155
|
+
// faulty caller signal can't error out combineLatest and tear down the whole aggregate.
|
|
156
|
+
return extraServices[serviceId].pipe((0, rxjs_1.catchError)(() => (0, rxjs_1.of)(models_1.ServiceConnection.UNKNOWN)));
|
|
157
|
+
}
|
|
158
|
+
return (0, rxjs_1.of)(models_1.ServiceConnection.UNKNOWN);
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* A service's bulk (per-project) `connections` endpoint, polled every `pollMs`. One poll per project,
|
|
162
|
+
* service and interval is shared by every callsign and subscriber. A failed poll emits `undefined`
|
|
163
|
+
* rather than erroring, so one bad poll doesn't end the stream.
|
|
164
|
+
*/
|
|
165
|
+
getProjectConnections(projectId, serviceId, pollMs) {
|
|
166
|
+
const url = (0, connectivity_1.buildConnectionsUrl)(serviceId, this.config.url, projectId, undefined, this.config.insecure);
|
|
167
|
+
return sharedStreams_1.sharedStreamPool.get(['connections', this.configKey, url, pollMs], () => {
|
|
168
|
+
return (0, rxjs_1.timer)(0, pollMs).pipe((0, rxjs_1.switchMap)(() => {
|
|
169
|
+
return (0, rxjs_1.from)(this.callGet(url, `Failed to get connection statuses for project ${projectId}.`)).pipe(
|
|
170
|
+
// Go encodes an empty map as null: a successful poll in which nobody is connected.
|
|
171
|
+
(0, rxjs_1.map)((connections) => connections ?? {}), (0, rxjs_1.catchError)(() => (0, rxjs_1.of)(undefined)));
|
|
172
|
+
}));
|
|
173
|
+
}, { replay: true });
|
|
174
|
+
}
|
|
109
175
|
}
|
|
110
176
|
exports.RobotStatusService = RobotStatusService;
|
package/cjs/services/index.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { IConnectedCallsign, RobotConnectivity, RobotConnectivityStatus, ServiceConnection } from '../../models';
|
|
2
|
-
import { Observable } from 'rxjs';
|
|
3
2
|
/**
|
|
4
3
|
* Service id → public path prefix, for services that expose the standard
|
|
5
4
|
* `connections` endpoint. New services adopting the convention are added here.
|
|
@@ -9,12 +8,13 @@ import { Observable } from 'rxjs';
|
|
|
9
8
|
export declare const CONNECTION_SERVICE_PREFIXES: Record<string, string>;
|
|
10
9
|
/**
|
|
11
10
|
* The telemetry-liveness signal is derived from heartbeat freshness rather than
|
|
12
|
-
* an HTTP endpoint, so it is handled specially
|
|
13
|
-
* the caller). See `getTelemetryLiveness`.
|
|
11
|
+
* an HTTP endpoint, so it is handled specially. See `getTelemetryLiveness`.
|
|
14
12
|
*/
|
|
15
13
|
export declare const TELEMETRY_LIVENESS_SERVICE = "telemetry-liveness";
|
|
16
14
|
/** The services evaluated by default. */
|
|
17
15
|
export declare const DEFAULT_EXPECTED_SERVICES: string[];
|
|
16
|
+
/** How often the bulk `connections` endpoints are polled by default (ms). */
|
|
17
|
+
export declare const DEFAULT_CONNECTIVITY_POLL_MS = 5000;
|
|
18
18
|
/**
|
|
19
19
|
* Floor for the connections-endpoint poll interval. Guards against a caller
|
|
20
20
|
* passing `0` (or any tiny value), which would otherwise poll the API on every
|
|
@@ -23,8 +23,16 @@ export declare const DEFAULT_EXPECTED_SERVICES: string[];
|
|
|
23
23
|
export declare const MIN_CONNECTIVITY_POLL_MS = 250;
|
|
24
24
|
/** Clamps a requested poll interval up to {@link MIN_CONNECTIVITY_POLL_MS}. */
|
|
25
25
|
export declare const clampPollInterval: (pollMs: number) => number;
|
|
26
|
-
/**
|
|
27
|
-
|
|
26
|
+
/**
|
|
27
|
+
* A bulk `connections` endpoint response: callsign → connection. A callsign that isn't listed is not
|
|
28
|
+
* connected (Teletubby lists only connected callsigns).
|
|
29
|
+
*/
|
|
30
|
+
export type ProjectConnections = Record<string, IConnectedCallsign>;
|
|
31
|
+
/**
|
|
32
|
+
* One poll of a bulk `connections` endpoint: the project's connections, or `undefined` when the poll
|
|
33
|
+
* failed — distinct from a successful but empty response, in which every callsign is disconnected.
|
|
34
|
+
*/
|
|
35
|
+
export type ProjectConnectionsPoll = ProjectConnections | undefined;
|
|
28
36
|
/**
|
|
29
37
|
* Builds the `connections` endpoint URL for a service — per-callsign when a
|
|
30
38
|
* callsign is given, otherwise the bulk per-project variant.
|
|
@@ -50,29 +58,10 @@ export declare const mapConnectionStatus: (connection?: IConnectedCallsign | nul
|
|
|
50
58
|
*/
|
|
51
59
|
export declare const aggregateConnectivity: (services: Record<string, ServiceConnection>) => RobotConnectivity;
|
|
52
60
|
/**
|
|
53
|
-
*
|
|
54
|
-
*
|
|
55
|
-
*
|
|
56
|
-
* degraded flash on a transient error.
|
|
57
|
-
*
|
|
58
|
-
* `pollMs` is floored at {@link MIN_CONNECTIVITY_POLL_MS} so the endpoint can't
|
|
59
|
-
* be polled unreasonably fast.
|
|
60
|
-
*/
|
|
61
|
-
export declare const getServiceConnectionChanges: (httpGet: ConnectionsHttpGet, url: string, pollMs?: number) => Observable<ServiceConnection>;
|
|
62
|
-
export interface ConnectivityDeps {
|
|
63
|
-
httpGet: ConnectionsHttpGet;
|
|
64
|
-
baseUrl: string;
|
|
65
|
-
insecure?: boolean;
|
|
66
|
-
/** The telemetry-liveness signal (from `getTelemetryLiveness`), folded in as one service. */
|
|
67
|
-
telemetryLiveness$: Observable<ServiceConnection>;
|
|
68
|
-
/** Caller-injected connectivity signals, keyed by service id, folded in on equal footing. */
|
|
69
|
-
extraServices?: Record<string, Observable<ServiceConnection>>;
|
|
70
|
-
}
|
|
71
|
-
/**
|
|
72
|
-
* Emits the robot's {@link RobotConnectivityStatus} — the per-service breakdown
|
|
73
|
-
* plus the aggregate verdict — for the configured `expectedServices`, plus any
|
|
74
|
-
* caller-injected `extraServices` (folded in on equal footing). HTTP services
|
|
75
|
-
* are polled; `telemetry-liveness` and injected services use their supplied
|
|
76
|
-
* observable; any unrecognised service id resolves to `UNKNOWN`.
|
|
61
|
+
* One callsign's {@link ServiceConnection} from a bulk poll. A failed poll is `UNKNOWN` (held
|
|
62
|
+
* transitional) rather than `DISCONNECTED`, to avoid a spurious degraded flash on a transient error;
|
|
63
|
+
* a callsign missing from a successful poll is `DISCONNECTED`.
|
|
77
64
|
*/
|
|
78
|
-
export declare const
|
|
65
|
+
export declare const getCallsignConnection: (poll: ProjectConnectionsPoll, callsign: string) => ServiceConnection;
|
|
66
|
+
/** Whether two connectivity statuses carry the same verdict and per-service breakdown. */
|
|
67
|
+
export declare const connectivityEquals: (a: RobotConnectivityStatus, b: RobotConnectivityStatus) => boolean;
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.connectivityEquals = exports.getCallsignConnection = exports.aggregateConnectivity = exports.mapConnectionStatus = exports.buildConnectionsUrl = exports.clampPollInterval = exports.MIN_CONNECTIVITY_POLL_MS = exports.DEFAULT_CONNECTIVITY_POLL_MS = exports.DEFAULT_EXPECTED_SERVICES = exports.TELEMETRY_LIVENESS_SERVICE = exports.CONNECTION_SERVICE_PREFIXES = void 0;
|
|
4
4
|
const api_1 = require("../../constants/api");
|
|
5
5
|
const models_1 = require("../../models");
|
|
6
|
-
const rxjs_1 = require("rxjs");
|
|
7
6
|
const formatServiceUrl_1 = require("../../helpers/formatServiceUrl");
|
|
8
7
|
/**
|
|
9
8
|
* Service id → public path prefix, for services that expose the standard
|
|
@@ -18,8 +17,7 @@ exports.CONNECTION_SERVICE_PREFIXES = {
|
|
|
18
17
|
};
|
|
19
18
|
/**
|
|
20
19
|
* The telemetry-liveness signal is derived from heartbeat freshness rather than
|
|
21
|
-
* an HTTP endpoint, so it is handled specially
|
|
22
|
-
* the caller). See `getTelemetryLiveness`.
|
|
20
|
+
* an HTTP endpoint, so it is handled specially. See `getTelemetryLiveness`.
|
|
23
21
|
*/
|
|
24
22
|
exports.TELEMETRY_LIVENESS_SERVICE = 'telemetry-liveness';
|
|
25
23
|
/** The services evaluated by default. */
|
|
@@ -29,7 +27,8 @@ exports.DEFAULT_EXPECTED_SERVICES = [
|
|
|
29
27
|
'robot-services',
|
|
30
28
|
'robot-telemetry',
|
|
31
29
|
];
|
|
32
|
-
|
|
30
|
+
/** How often the bulk `connections` endpoints are polled by default (ms). */
|
|
31
|
+
exports.DEFAULT_CONNECTIVITY_POLL_MS = 5000;
|
|
33
32
|
/**
|
|
34
33
|
* Floor for the connections-endpoint poll interval. Guards against a caller
|
|
35
34
|
* passing `0` (or any tiny value), which would otherwise poll the API on every
|
|
@@ -90,20 +89,19 @@ const aggregateConnectivity = (services) => {
|
|
|
90
89
|
};
|
|
91
90
|
exports.aggregateConnectivity = aggregateConnectivity;
|
|
92
91
|
/**
|
|
93
|
-
*
|
|
94
|
-
*
|
|
95
|
-
*
|
|
96
|
-
* degraded flash on a transient error.
|
|
97
|
-
*
|
|
98
|
-
* `pollMs` is floored at {@link MIN_CONNECTIVITY_POLL_MS} so the endpoint can't
|
|
99
|
-
* be polled unreasonably fast.
|
|
92
|
+
* One callsign's {@link ServiceConnection} from a bulk poll. A failed poll is `UNKNOWN` (held
|
|
93
|
+
* transitional) rather than `DISCONNECTED`, to avoid a spurious degraded flash on a transient error;
|
|
94
|
+
* a callsign missing from a successful poll is `DISCONNECTED`.
|
|
100
95
|
*/
|
|
101
|
-
const
|
|
102
|
-
|
|
103
|
-
return
|
|
104
|
-
|
|
96
|
+
const getCallsignConnection = (poll, callsign) => {
|
|
97
|
+
if (poll === undefined)
|
|
98
|
+
return models_1.ServiceConnection.UNKNOWN;
|
|
99
|
+
if (!Object.prototype.hasOwnProperty.call(poll, callsign))
|
|
100
|
+
return models_1.ServiceConnection.DISCONNECTED;
|
|
101
|
+
return (0, exports.mapConnectionStatus)(poll[callsign]);
|
|
105
102
|
};
|
|
106
|
-
exports.
|
|
103
|
+
exports.getCallsignConnection = getCallsignConnection;
|
|
104
|
+
/** Whether two connectivity statuses carry the same verdict and per-service breakdown. */
|
|
107
105
|
const connectivityEquals = (a, b) => {
|
|
108
106
|
if (a.overall !== b.overall)
|
|
109
107
|
return false;
|
|
@@ -112,44 +110,4 @@ const connectivityEquals = (a, b) => {
|
|
|
112
110
|
return false;
|
|
113
111
|
return keys.every((key) => a.services[key] === b.services[key]);
|
|
114
112
|
};
|
|
115
|
-
|
|
116
|
-
* Emits the robot's {@link RobotConnectivityStatus} — the per-service breakdown
|
|
117
|
-
* plus the aggregate verdict — for the configured `expectedServices`, plus any
|
|
118
|
-
* caller-injected `extraServices` (folded in on equal footing). HTTP services
|
|
119
|
-
* are polled; `telemetry-liveness` and injected services use their supplied
|
|
120
|
-
* observable; any unrecognised service id resolves to `UNKNOWN`.
|
|
121
|
-
*/
|
|
122
|
-
const getConnectivityChanges = (deps, projectId, callsign, expectedServices = exports.DEFAULT_EXPECTED_SERVICES, pollMs = DEFAULT_CONNECTIVITY_POLL_MS) => {
|
|
123
|
-
const extraServices = deps.extraServices ?? {};
|
|
124
|
-
const serviceIds = [...expectedServices, ...Object.keys(extraServices).filter((id) => !expectedServices.includes(id))];
|
|
125
|
-
// combineLatest([]) completes without emitting; emit an explicit empty/offline status instead.
|
|
126
|
-
if (serviceIds.length === 0) {
|
|
127
|
-
return (0, rxjs_1.of)({ overall: models_1.RobotConnectivity.OFFLINE, services: {} });
|
|
128
|
-
}
|
|
129
|
-
const perService = serviceIds.map((serviceId) => {
|
|
130
|
-
let source$;
|
|
131
|
-
if (serviceId === exports.TELEMETRY_LIVENESS_SERVICE) {
|
|
132
|
-
source$ = deps.telemetryLiveness$;
|
|
133
|
-
}
|
|
134
|
-
else if (Object.prototype.hasOwnProperty.call(exports.CONNECTION_SERVICE_PREFIXES, serviceId)) {
|
|
135
|
-
const url = (0, exports.buildConnectionsUrl)(serviceId, deps.baseUrl, projectId, callsign, deps.insecure);
|
|
136
|
-
source$ = (0, exports.getServiceConnectionChanges)(deps.httpGet, url, pollMs);
|
|
137
|
-
}
|
|
138
|
-
else if (Object.prototype.hasOwnProperty.call(extraServices, serviceId)) {
|
|
139
|
-
// Contain an injected observable's errors as UNKNOWN, mirroring the built-in sources, so a
|
|
140
|
-
// faulty caller signal can't error out combineLatest and tear down the whole aggregate.
|
|
141
|
-
source$ = extraServices[serviceId].pipe((0, rxjs_1.catchError)(() => (0, rxjs_1.of)(models_1.ServiceConnection.UNKNOWN)));
|
|
142
|
-
}
|
|
143
|
-
else {
|
|
144
|
-
source$ = (0, rxjs_1.of)(models_1.ServiceConnection.UNKNOWN);
|
|
145
|
-
}
|
|
146
|
-
return source$.pipe((0, rxjs_1.startWith)(models_1.ServiceConnection.UNKNOWN), (0, rxjs_1.map)((connection) => ({ serviceId, connection })));
|
|
147
|
-
});
|
|
148
|
-
return (0, rxjs_1.combineLatest)(perService).pipe((0, rxjs_1.map)((entries) => {
|
|
149
|
-
const services = {};
|
|
150
|
-
for (const { serviceId, connection } of entries)
|
|
151
|
-
services[serviceId] = connection;
|
|
152
|
-
return { overall: (0, exports.aggregateConnectivity)(services), services };
|
|
153
|
-
}), (0, rxjs_1.distinctUntilChanged)(connectivityEquals));
|
|
154
|
-
};
|
|
155
|
-
exports.getConnectivityChanges = getConnectivityChanges;
|
|
113
|
+
exports.connectivityEquals = connectivityEquals;
|
|
@@ -7,6 +7,13 @@ export declare const ROBOT_STATUS_SOURCE = "/diagnostics/robot/status";
|
|
|
7
7
|
export declare const LEGACY_HEARTBEAT_SOURCE = "/rocos/agent/telemetry/heartbeat";
|
|
8
8
|
/** The per-contributor breakdown behind the reported status (health + readiness). */
|
|
9
9
|
export declare const ROBOT_STATUS_CONTRIBUTORS_SOURCE = "/diagnostics/robot/status/contributors";
|
|
10
|
+
/** How long without a liveness message before `telemetry-liveness` reports `DISCONNECTED` (ms). */
|
|
11
|
+
export declare const DEFAULT_HEARTBEAT_TIMEOUT_MS = 5000;
|
|
12
|
+
/**
|
|
13
|
+
* The telemetry these streams subscribe through. `RobotStatusService` passes a pooled implementation,
|
|
14
|
+
* so every status stream for a robot shares one subscription per topic.
|
|
15
|
+
*/
|
|
16
|
+
export type StatusTelemetry = Pick<TelemetryService, 'subscribe'>;
|
|
10
17
|
export interface ReportedRobotStatus {
|
|
11
18
|
health: RobotHealth;
|
|
12
19
|
readiness: RobotReadiness;
|
|
@@ -29,7 +36,7 @@ export declare const parseRobotReadiness: (value: unknown) => RobotReadiness;
|
|
|
29
36
|
* preserves today's "online ⇒ green" behaviour for agents not yet emitting the
|
|
30
37
|
* new topic.
|
|
31
38
|
*/
|
|
32
|
-
export declare const getReportedStatusChanges: (telemetry:
|
|
39
|
+
export declare const getReportedStatusChanges: (telemetry: StatusTelemetry, projectId: string, callsign: string) => Observable<ReportedRobotStatus>;
|
|
33
40
|
/**
|
|
34
41
|
* Emits the per-contributor breakdown behind the robot's reported health and
|
|
35
42
|
* readiness, from the agent's `robot/status/contributors` topic. Each
|
|
@@ -40,7 +47,7 @@ export declare const getReportedStatusChanges: (telemetry: TelemetryService, pro
|
|
|
40
47
|
* emit immediately, and — like {@link getReportedStatusChanges} — a telemetry
|
|
41
48
|
* error falls back to an empty breakdown rather than terminating the stream.
|
|
42
49
|
*/
|
|
43
|
-
export declare const getStatusContributorsChanges: (telemetry:
|
|
50
|
+
export declare const getStatusContributorsChanges: (telemetry: StatusTelemetry, projectId: string, callsign: string) => Observable<RobotStatusContributors>;
|
|
44
51
|
/**
|
|
45
52
|
* Emits the robot's telemetry latency in milliseconds, once per liveness message (from either the
|
|
46
53
|
* new `robot/status` topic or the legacy heartbeat — the same messages {@link getTelemetryLiveness}
|
|
@@ -52,7 +59,7 @@ export declare const getStatusContributorsChanges: (telemetry: TelemetryService,
|
|
|
52
59
|
* {@link getTelemetryLiveness} to tell a stale value from a live one. A telemetry error completes
|
|
53
60
|
* the stream rather than erroring it.
|
|
54
61
|
*/
|
|
55
|
-
export declare const getTelemetryLatencyChanges: (telemetry:
|
|
62
|
+
export declare const getTelemetryLatencyChanges: (telemetry: StatusTelemetry, projectId: string, callsign: string, now: () => number) => Observable<number>;
|
|
56
63
|
/**
|
|
57
64
|
* Emits the `telemetry-liveness` connectivity signal: whether a heartbeat (from
|
|
58
65
|
* either the new `robot/status` topic or the legacy heartbeat) has been received
|
|
@@ -60,4 +67,4 @@ export declare const getTelemetryLatencyChanges: (telemetry: TelemetryService, p
|
|
|
60
67
|
* but spans both topics and maps onto {@link ServiceConnection} so it can be
|
|
61
68
|
* folded into connectivity aggregation as just another service entry.
|
|
62
69
|
*/
|
|
63
|
-
export declare const getTelemetryLiveness: (telemetry:
|
|
70
|
+
export declare const getTelemetryLiveness: (telemetry: StatusTelemetry, projectId: string, callsign: string, heartbeatTimeoutMs?: number, intervalMs?: number) => Observable<ServiceConnection>;
|