@dronedeploy/rocos-js-sdk 4.4.16-rc.1 → 4.5.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.
- 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 +8 -0
- package/cjs/services/RobotStatusService.js +11 -0
- package/cjs/services/index.d.ts +1 -0
- package/cjs/services/robot-status/reportedStatus.d.ts +12 -0
- package/cjs/services/robot-status/reportedStatus.js +18 -1
- 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 +8 -0
- package/esm/services/RobotStatusService.js +12 -1
- package/esm/services/index.d.ts +1 -0
- package/esm/services/robot-status/reportedStatus.d.ts +12 -0
- package/esm/services/robot-status/reportedStatus.js +17 -1
- 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
|
*
|
|
@@ -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);
|
package/cjs/services/index.d.ts
CHANGED
|
@@ -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
|
package/esm/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/esm/constants/api.js
CHANGED
|
@@ -131,6 +131,8 @@ export const API_GRAPHS_MAPS_DEPLOYED_URL = 'https://{url}/graphs/projects/{proj
|
|
|
131
131
|
export const API_GRAPHS_MAPS_UNION_URL = 'https://{url}/graphs/projects/{projectId}/maps/union';
|
|
132
132
|
export const API_GRAPHS_MAP_ID_URL = 'https://{url}/graphs/projects/{projectId}/maps/{mapId}';
|
|
133
133
|
export const API_GRAPHS_MAP_CONTENT_URL = 'https://{url}/graphs/projects/{projectId}/maps/{mapId}/content';
|
|
134
|
+
export const API_GRAPHS_MAP_EXTERNAL_DATA_UPLOAD_URL = 'https://{url}/graphs/projects/{projectId}/maps/externaldata';
|
|
135
|
+
export const API_GRAPHS_MAP_EXTERNAL_DATA_URL = 'https://{url}/graphs/projects/{projectId}/maps/externaldata/{hash}';
|
|
134
136
|
export const API_GRAPHS_MAP_METADATA_URL = 'https://{url}/graphs/projects/{projectId}/maps/{mapId}/metadata';
|
|
135
137
|
export const API_GRAPHS_MAP_NODES_ADD_URL = 'https://{url}/graphs/projects/{projectId}/maps/{mapId}/nodes/add';
|
|
136
138
|
export const 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;
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import { HttpError, RocosError } from '../models';
|
|
2
2
|
import { getURLSearchParams } from '../helpers';
|
|
3
3
|
import { RocosStore } from '../store/RocosStore';
|
|
4
|
+
const isBinaryPayload = (payload) => {
|
|
5
|
+
if (typeof Blob !== 'undefined' && payload instanceof Blob)
|
|
6
|
+
return true;
|
|
7
|
+
return payload instanceof ArrayBuffer || ArrayBuffer.isView(payload);
|
|
8
|
+
};
|
|
4
9
|
export class BaseServiceAbstract {
|
|
5
10
|
constructor(config) {
|
|
6
11
|
this.config = config;
|
|
@@ -37,6 +42,10 @@ export class BaseServiceAbstract {
|
|
|
37
42
|
if (typeof FormData !== 'undefined' && payload instanceof FormData) {
|
|
38
43
|
requestConfig.body = payload;
|
|
39
44
|
}
|
|
45
|
+
else if (isBinaryPayload(payload)) {
|
|
46
|
+
// Raw bytes go up as-is; the caller names their media type in config.headers.
|
|
47
|
+
requestConfig.body = payload;
|
|
48
|
+
}
|
|
40
49
|
else if (payload) {
|
|
41
50
|
requestConfig.body = JSON.stringify(payload);
|
|
42
51
|
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
|
*
|
|
@@ -1,5 +1,5 @@
|
|
|
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_NEW_URL, API_GRAPHS_MAPS_UNION_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
|
-
import { RocosError, errorCodes } from '../models';
|
|
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_NEW_URL, API_GRAPHS_MAPS_UNION_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_EXTERNAL_DATA_UPLOAD_URL, API_GRAPHS_MAP_EXTERNAL_DATA_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
|
+
import { RocosError, errorCodes, } from '../models';
|
|
3
3
|
import { BaseServiceAbstract } from './BaseServiceAbstract';
|
|
4
4
|
import { RocosLogger } from '../logger/RocosLogger';
|
|
5
5
|
import { formatServiceUrl } from '../helpers/formatServiceUrl';
|
|
@@ -151,6 +151,43 @@ export class MapService extends BaseServiceAbstract {
|
|
|
151
151
|
mapId,
|
|
152
152
|
}, this.config.insecure), content, 'Failed to update map content.');
|
|
153
153
|
}
|
|
154
|
+
/**
|
|
155
|
+
* Downloads the bytes behind a map node's or edge's `externalData` entry.
|
|
156
|
+
*
|
|
157
|
+
* The entry names the bytes by `hash`; giraffe answers with a redirect to a
|
|
158
|
+
* signed download URL, which `fetch` follows. The returned blob carries the
|
|
159
|
+
* content type the bytes were stored with. An entry whose `encoding` is
|
|
160
|
+
* `b64` holds base64 text, which the caller decodes.
|
|
161
|
+
*
|
|
162
|
+
* @param projectId Project ID
|
|
163
|
+
* @param hash The entry's `hash`
|
|
164
|
+
*/
|
|
165
|
+
async getExternalData(projectId, hash) {
|
|
166
|
+
return this.callGet(formatServiceUrl(API_GRAPHS_MAP_EXTERNAL_DATA_URL, {
|
|
167
|
+
url: this.config.url,
|
|
168
|
+
projectId,
|
|
169
|
+
hash: encodeURIComponent(hash),
|
|
170
|
+
}, this.config.insecure), 'Failed to get map external data.', undefined, { responseType: 'blob' });
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* Stores bytes as map external data, for a node's or edge's `externalData`
|
|
174
|
+
* entry to name by the returned `hash`.
|
|
175
|
+
*
|
|
176
|
+
* Giraffe hashes the bytes (sha256) and keeps them in the project's map-asset
|
|
177
|
+
* store under that hash with the given media type, which is what
|
|
178
|
+
* {@link getExternalData} later serves. Storing the same bytes twice is
|
|
179
|
+
* harmless. The server caps one item at 64 MiB.
|
|
180
|
+
*
|
|
181
|
+
* @param projectId Project ID
|
|
182
|
+
* @param data The bytes to store
|
|
183
|
+
* @param contentType Their media type; `application/octet-stream` when omitted
|
|
184
|
+
*/
|
|
185
|
+
async putExternalData(projectId, data, contentType = 'application/octet-stream') {
|
|
186
|
+
return this.callPut(formatServiceUrl(API_GRAPHS_MAP_EXTERNAL_DATA_UPLOAD_URL, {
|
|
187
|
+
url: this.config.url,
|
|
188
|
+
projectId,
|
|
189
|
+
}, this.config.insecure), data, 'Failed to store map external data.', { headers: { 'Content-Type': contentType } });
|
|
190
|
+
}
|
|
154
191
|
/**
|
|
155
192
|
* Begins uploading a map from the agent
|
|
156
193
|
*
|
|
@@ -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);
|
package/esm/services/index.d.ts
CHANGED
|
@@ -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
|