@dronedeploy/rocos-js-sdk 4.5.1 → 4.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cjs/constants/api.d.ts +2 -0
- package/cjs/constants/api.js +4 -2
- package/cjs/models/index.d.ts +1 -0
- package/cjs/models/index.js +1 -0
- package/cjs/models/maps/MapLocation.d.ts +60 -0
- package/cjs/models/maps/MapLocation.js +2 -0
- package/cjs/services/MapService.d.ts +32 -0
- package/cjs/services/MapService.js +35 -0
- package/cjs/services/RobotStatusService.d.ts +22 -3
- package/cjs/services/RobotStatusService.js +79 -13
- 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/index.d.ts +1 -0
- package/esm/models/index.js +1 -0
- package/esm/models/maps/MapLocation.d.ts +60 -0
- package/esm/models/maps/MapLocation.js +1 -0
- package/esm/services/MapService.d.ts +32 -0
- package/esm/services/MapService.js +36 -1
- package/esm/services/RobotStatusService.d.ts +22 -3
- package/esm/services/RobotStatusService.js +82 -16
- 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
|
@@ -139,6 +139,8 @@ export declare const API_GRAPHS_MAP_EDGES_ADD_URL = "https://{url}/graphs/projec
|
|
|
139
139
|
export declare const API_GRAPHS_MAP_EDGES_ADD_TRANSFORM_URL = "https://{url}/graphs/projects/{projectId}/maps/{mapId}/edges/add/transform";
|
|
140
140
|
export declare const API_GRAPHS_MAP_EDGE_URL = "https://{url}/graphs/projects/{projectId}/maps/{mapId}/edges/{edgeId}";
|
|
141
141
|
export declare const API_GRAPHS_MAP_PATHS_URL = "https://{url}/graphs/projects/{projectId}/maps/{mapId}/paths";
|
|
142
|
+
export declare const API_GRAPHS_MAP_PATHS_ADD_LOCATION_URL = "https://{url}/graphs/projects/{projectId}/maps/{mapId}/paths/add-location";
|
|
143
|
+
export declare const API_GRAPHS_MAP_PATHS_ADD_LOCATIONS_URL = "https://{url}/graphs/projects/{projectId}/maps/{mapId}/paths/add-locations";
|
|
142
144
|
export declare const API_GRAPHS_MAP_PATH_URL = "https://{url}/graphs/projects/{projectId}/maps/{mapId}/paths/{pathId}";
|
|
143
145
|
export declare const API_GRAPHS_MAP_PATH_APPEND_URL = "https://{url}/graphs/projects/{projectId}/maps/{mapId}/paths/{pathId}/append";
|
|
144
146
|
export declare const API_GRAPHS_MAP_PATH_APPEND_TRANSFORMABLE_URL = "https://{url}/graphs/projects/{projectId}/maps/{mapId}/paths/{pathId}/append/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 = exports.API_GRAPHS_OBSERVATION_KEYS_URL = exports.API_GRAPHS_OBSERVATIONS_URL = void 0;
|
|
5
|
+
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_ADD_LOCATIONS_URL = exports.API_GRAPHS_MAP_PATHS_ADD_LOCATION_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 = exports.API_GRAPHS_PANORAMA_OBSERVATIONS_URL = exports.API_GRAPHS_PANORAMA = 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';
|
|
@@ -147,6 +147,8 @@ exports.API_GRAPHS_MAP_EDGES_ADD_URL = 'https://{url}/graphs/projects/{projectId
|
|
|
147
147
|
exports.API_GRAPHS_MAP_EDGES_ADD_TRANSFORM_URL = 'https://{url}/graphs/projects/{projectId}/maps/{mapId}/edges/add/transform';
|
|
148
148
|
exports.API_GRAPHS_MAP_EDGE_URL = 'https://{url}/graphs/projects/{projectId}/maps/{mapId}/edges/{edgeId}';
|
|
149
149
|
exports.API_GRAPHS_MAP_PATHS_URL = 'https://{url}/graphs/projects/{projectId}/maps/{mapId}/paths';
|
|
150
|
+
exports.API_GRAPHS_MAP_PATHS_ADD_LOCATION_URL = 'https://{url}/graphs/projects/{projectId}/maps/{mapId}/paths/add-location';
|
|
151
|
+
exports.API_GRAPHS_MAP_PATHS_ADD_LOCATIONS_URL = 'https://{url}/graphs/projects/{projectId}/maps/{mapId}/paths/add-locations';
|
|
150
152
|
exports.API_GRAPHS_MAP_PATH_URL = 'https://{url}/graphs/projects/{projectId}/maps/{mapId}/paths/{pathId}';
|
|
151
153
|
exports.API_GRAPHS_MAP_PATH_APPEND_URL = 'https://{url}/graphs/projects/{projectId}/maps/{mapId}/paths/{pathId}/append';
|
|
152
154
|
exports.API_GRAPHS_MAP_PATH_APPEND_TRANSFORMABLE_URL = 'https://{url}/graphs/projects/{projectId}/maps/{mapId}/paths/{pathId}/append/transformable';
|
package/cjs/models/index.d.ts
CHANGED
|
@@ -53,6 +53,7 @@ export * from './maps/Map';
|
|
|
53
53
|
export * from './maps/MapContent';
|
|
54
54
|
export * from './maps/MapEdge';
|
|
55
55
|
export * from './maps/MapNode';
|
|
56
|
+
export * from './maps/MapLocation';
|
|
56
57
|
export * from './maps/MapPath';
|
|
57
58
|
export * from './maps/Panorama';
|
|
58
59
|
export * from './message';
|
package/cjs/models/index.js
CHANGED
|
@@ -69,6 +69,7 @@ __exportStar(require("./maps/Map"), exports);
|
|
|
69
69
|
__exportStar(require("./maps/MapContent"), exports);
|
|
70
70
|
__exportStar(require("./maps/MapEdge"), exports);
|
|
71
71
|
__exportStar(require("./maps/MapNode"), exports);
|
|
72
|
+
__exportStar(require("./maps/MapLocation"), exports);
|
|
72
73
|
__exportStar(require("./maps/MapPath"), exports);
|
|
73
74
|
__exportStar(require("./maps/Panorama"), exports);
|
|
74
75
|
__exportStar(require("./message"), exports);
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Where a location comes from: `explore` is a DroneDeploy location, `progress` a Progress AI one.
|
|
3
|
+
* Progress AI is called as the requesting user, so `progress` needs a user token.
|
|
4
|
+
*/
|
|
5
|
+
export type LocationKind = 'explore' | 'progress';
|
|
6
|
+
/** Options shared by `MapService.addLocation` and `MapService.addLocations`. */
|
|
7
|
+
export interface LocationPathOptions {
|
|
8
|
+
/** Node type of each vertex; `FRAME` when omitted. Server-managed types are refused (400). */
|
|
9
|
+
nodeType?: string;
|
|
10
|
+
}
|
|
11
|
+
/** Body of `MapService.addLocation`. */
|
|
12
|
+
export interface AddLocationPathRequest extends LocationPathOptions {
|
|
13
|
+
kind: LocationKind;
|
|
14
|
+
/** The location's id, with or without its GraphQL type prefix. */
|
|
15
|
+
locationId: string;
|
|
16
|
+
/**
|
|
17
|
+
* The path's parent node id. When omitted it is `location-<location name>` (slugged, with the
|
|
18
|
+
* location id appended when that id is taken), and a location already written is refused (409).
|
|
19
|
+
* Naming it asks for another path of the same location, and only that id has to be free.
|
|
20
|
+
*/
|
|
21
|
+
pathId?: string;
|
|
22
|
+
}
|
|
23
|
+
/** Body of `MapService.addLocations`. */
|
|
24
|
+
export interface AddLocationPathsRequest extends LocationPathOptions {
|
|
25
|
+
/** At least one kind. */
|
|
26
|
+
kinds: LocationKind[];
|
|
27
|
+
/** Only locations on these levels (ids, with or without the `Level:` prefix); every level when omitted. */
|
|
28
|
+
levelIds?: string[];
|
|
29
|
+
}
|
|
30
|
+
/** The closed path written for a location. */
|
|
31
|
+
export interface AddLocationPathResponse {
|
|
32
|
+
pathId: string;
|
|
33
|
+
/** The vertex node ids, in ring order. */
|
|
34
|
+
memberIds: string[];
|
|
35
|
+
kind: LocationKind;
|
|
36
|
+
locationId: string;
|
|
37
|
+
name: string;
|
|
38
|
+
levelId: string;
|
|
39
|
+
/** The level's `overlay-<level>-centroid` frame the vertices are positioned in. */
|
|
40
|
+
frame: string;
|
|
41
|
+
/** Set when the level's alignment is marked unverified. */
|
|
42
|
+
unverifiedAlignment: boolean;
|
|
43
|
+
}
|
|
44
|
+
export type LocationPathStatus = 'created' | 'skipped' | 'failed';
|
|
45
|
+
/**
|
|
46
|
+
* One location's outcome in `MapService.addLocations`. `reason` says why a location was
|
|
47
|
+
* `skipped` or `failed`. A result with no `locationId` reports a failure to list that kind.
|
|
48
|
+
*/
|
|
49
|
+
export interface LocationPathResult {
|
|
50
|
+
kind: LocationKind;
|
|
51
|
+
locationId?: string;
|
|
52
|
+
name?: string;
|
|
53
|
+
levelId?: string;
|
|
54
|
+
pathId?: string;
|
|
55
|
+
status: LocationPathStatus;
|
|
56
|
+
reason?: string;
|
|
57
|
+
}
|
|
58
|
+
export interface AddLocationPathsResponse {
|
|
59
|
+
results: LocationPathResult[];
|
|
60
|
+
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { AddEdgeRequest, AddEdgeResponse, AddTransformEdgeRequest } from '../models/maps/MapEdge';
|
|
2
|
+
import { AddLocationPathRequest, AddLocationPathResponse, AddLocationPathsRequest, AddLocationPathsResponse } from '../models/maps/MapLocation';
|
|
2
3
|
import { AddNodeRequest, AddNodeResponse, AddTransformableNodeRequest } from '../models/maps/MapNode';
|
|
3
4
|
import { AddPanoramaRequest, AddPanoramaResponse, CreateObservation, Observation } from '../models/maps/Panorama';
|
|
4
5
|
import { AppendPathPointsResponse, AppendToPathRequest, AppendTransformablePointsRequest, ListPathsFilter, MapPath, ReplacePathRequest } from '../models/maps/MapPath';
|
|
@@ -447,6 +448,37 @@ export declare class MapService extends BaseServiceAbstract implements IBaseServ
|
|
|
447
448
|
* @param body The path's desired state.
|
|
448
449
|
*/
|
|
449
450
|
replacePath(projectId: string, mapId: string, pathId: string, body: ReplacePathRequest): Promise<void>;
|
|
451
|
+
/**
|
|
452
|
+
* Write one DroneDeploy (`explore`) or Progress AI (`progress`) location into a map as a
|
|
453
|
+
* closed path, positioned in its level's `overlay-<level>-centroid` frame through the
|
|
454
|
+
* level's alignment, so it lands on the plan features it was traced over. See
|
|
455
|
+
* {@link AddLocationPathRequest} for the options.
|
|
456
|
+
*
|
|
457
|
+
* A location that cannot be placed is refused with 409 (exterior or level-less, on a level
|
|
458
|
+
* that is not aligned, or on a level whose alignment has no centroid frame yet), as is one
|
|
459
|
+
* whose path already exists. Use {@link addLocations} to add many and get a per-location
|
|
460
|
+
* outcome instead of an error.
|
|
461
|
+
*
|
|
462
|
+
* @param projectId The ID of the project the map belongs to.
|
|
463
|
+
* @param mapId The ID of the map to add the path to.
|
|
464
|
+
* @param body The location to add.
|
|
465
|
+
* @returns The path written: its id, its vertex node ids and the frame it sits in.
|
|
466
|
+
*/
|
|
467
|
+
addLocation(projectId: string, mapId: string, body: AddLocationPathRequest): Promise<AddLocationPathResponse>;
|
|
468
|
+
/**
|
|
469
|
+
* Write every location of the given kinds (or only those on the given levels) into a map as
|
|
470
|
+
* closed paths, one each, placed as {@link addLocation} places one. Runs synchronously on the
|
|
471
|
+
* server and answers 200 whatever the mix: a location that cannot be placed or already has a
|
|
472
|
+
* path is reported `skipped`, other failures `failed`, each with a `reason`. A kind that cannot
|
|
473
|
+
* be listed at all (for example Progress AI is not configured, or the call has no user token)
|
|
474
|
+
* yields one `failed` result for that kind with no `locationId`.
|
|
475
|
+
*
|
|
476
|
+
* @param projectId The ID of the project the map belongs to.
|
|
477
|
+
* @param mapId The ID of the map to add the paths to.
|
|
478
|
+
* @param body The kinds and optional level filter.
|
|
479
|
+
* @returns The outcome for each location.
|
|
480
|
+
*/
|
|
481
|
+
addLocations(projectId: string, mapId: string, body: AddLocationPathsRequest): Promise<AddLocationPathsResponse>;
|
|
450
482
|
/**
|
|
451
483
|
* Delete a path's structure, mirroring the agent's `paths/delete`: idempotent (a missing
|
|
452
484
|
* path still returns success), member nodes preserved by default, and the parent node
|
|
@@ -608,6 +608,41 @@ class MapService extends BaseServiceAbstract_1.BaseServiceAbstract {
|
|
|
608
608
|
};
|
|
609
609
|
await this.callPut((0, formatServiceUrl_1.formatServiceUrl)(api_1.API_GRAPHS_MAP_PATH_URL, { url: this.config.url, projectId, mapId, pathId }, this.config.insecure), wireBody, 'Failed to replace path.');
|
|
610
610
|
}
|
|
611
|
+
/**
|
|
612
|
+
* Write one DroneDeploy (`explore`) or Progress AI (`progress`) location into a map as a
|
|
613
|
+
* closed path, positioned in its level's `overlay-<level>-centroid` frame through the
|
|
614
|
+
* level's alignment, so it lands on the plan features it was traced over. See
|
|
615
|
+
* {@link AddLocationPathRequest} for the options.
|
|
616
|
+
*
|
|
617
|
+
* A location that cannot be placed is refused with 409 (exterior or level-less, on a level
|
|
618
|
+
* that is not aligned, or on a level whose alignment has no centroid frame yet), as is one
|
|
619
|
+
* whose path already exists. Use {@link addLocations} to add many and get a per-location
|
|
620
|
+
* outcome instead of an error.
|
|
621
|
+
*
|
|
622
|
+
* @param projectId The ID of the project the map belongs to.
|
|
623
|
+
* @param mapId The ID of the map to add the path to.
|
|
624
|
+
* @param body The location to add.
|
|
625
|
+
* @returns The path written: its id, its vertex node ids and the frame it sits in.
|
|
626
|
+
*/
|
|
627
|
+
addLocation(projectId, mapId, body) {
|
|
628
|
+
return this.callPost((0, formatServiceUrl_1.formatServiceUrl)(api_1.API_GRAPHS_MAP_PATHS_ADD_LOCATION_URL, { url: this.config.url, projectId, mapId }, this.config.insecure), body, 'Failed to add location.');
|
|
629
|
+
}
|
|
630
|
+
/**
|
|
631
|
+
* Write every location of the given kinds (or only those on the given levels) into a map as
|
|
632
|
+
* closed paths, one each, placed as {@link addLocation} places one. Runs synchronously on the
|
|
633
|
+
* server and answers 200 whatever the mix: a location that cannot be placed or already has a
|
|
634
|
+
* path is reported `skipped`, other failures `failed`, each with a `reason`. A kind that cannot
|
|
635
|
+
* be listed at all (for example Progress AI is not configured, or the call has no user token)
|
|
636
|
+
* yields one `failed` result for that kind with no `locationId`.
|
|
637
|
+
*
|
|
638
|
+
* @param projectId The ID of the project the map belongs to.
|
|
639
|
+
* @param mapId The ID of the map to add the paths to.
|
|
640
|
+
* @param body The kinds and optional level filter.
|
|
641
|
+
* @returns The outcome for each location.
|
|
642
|
+
*/
|
|
643
|
+
addLocations(projectId, mapId, body) {
|
|
644
|
+
return this.callPost((0, formatServiceUrl_1.formatServiceUrl)(api_1.API_GRAPHS_MAP_PATHS_ADD_LOCATIONS_URL, { url: this.config.url, projectId, mapId }, this.config.insecure), body, 'Failed to add locations.');
|
|
645
|
+
}
|
|
611
646
|
/**
|
|
612
647
|
* Delete a path's structure, mirroring the agent's `paths/delete`: idempotent (a missing
|
|
613
648
|
* path still returns success), member nodes preserved by default, and the parent node
|
|
@@ -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;
|
|
@@ -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;
|