@dronedeploy/rocos-js-sdk 4.5.0 → 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.
@@ -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";
@@ -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.API_GRAPHS_OBSERVATION_KEYS_URL = exports.API_GRAPHS_OBSERVATIONS_URL = 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_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 = void 0;
5
+ exports.API_GRAPHS_PANORAMA_OBSERVATIONS_URL = exports.API_GRAPHS_PANORAMA = exports.API_GRAPHS_PANORAMAS_URL = exports.API_GRAPHS_MAPS_GEOJSON_URL = exports.API_GRAPHS_MAPS_DEPLOY_URL = exports.API_GRAPHS_MAPS_COPY_URL = exports.API_GRAPHS_MAP_PATH_APPEND_TRANSFORMABLE_URL = exports.API_GRAPHS_MAP_PATH_APPEND_URL = exports.API_GRAPHS_MAP_PATH_URL = exports.API_GRAPHS_MAP_PATHS_URL = exports.API_GRAPHS_MAP_EDGE_URL = exports.API_GRAPHS_MAP_EDGES_ADD_TRANSFORM_URL = exports.API_GRAPHS_MAP_EDGES_ADD_URL = exports.API_GRAPHS_MAP_NODE_URL = exports.API_GRAPHS_MAP_NODES_ADD_TRANSFORMABLE_URL = exports.API_GRAPHS_MAP_NODES_ADD_URL = exports.API_GRAPHS_MAP_METADATA_URL = exports.API_GRAPHS_MAP_EXTERNAL_DATA_URL = exports.API_GRAPHS_MAP_EXTERNAL_DATA_UPLOAD_URL = exports.API_GRAPHS_MAP_CONTENT_URL = exports.API_GRAPHS_MAP_ID_URL = exports.API_GRAPHS_MAPS_UNION_URL = exports.API_GRAPHS_MAPS_DEPLOYED_URL = exports.API_GRAPHS_MAPS_NEW_URL = exports.API_GRAPHS_MAPS_URL = exports.API_DD_INTEGRATION_LEVELS_URL = exports.API_DD_INTEGRATION_LOCATIONS_URL = exports.API_DD_INTEGRATION_ISSUES_URL = exports.API_DD_INTEGRATION_OVERLAYS_URL = exports.API_DD_INTEGRATION_PLAN_BY_ID_URL = exports.API_DD_INTEGRATION_PLANS_URL = exports.API_SPOTTY_URL = exports.API_PROJECT_SCHEDULES_URL = exports.API_SOURCE_ID_URL = exports.API_SOURCE_URL = exports.API_SOURCE_SCHEMA_URL = exports.API_TEMPLATE_EXPORTER_URL = exports.API_TEMPLATE_PROVISION_ID_URL = exports.API_TEMPLATE_PROVISION_URL = exports.API_TEMPLATE_DEPLOY_URL = exports.API_PROJECT_PROFILE_DASHBOARD_CUSTOM_WIDGET_URL = exports.API_PROJECT_PROFILE_DASHBOARD_ID_URL = exports.API_PROJECT_PROFILE_DASHBOARD_URL = exports.API_PROJECT_CALLSIGN_STREAM_URL = exports.API_PROJECT_ROBOT_DASHBOARD_CUSTOM_WIDGET_URL = exports.API_PROJECT_ROBOT_DASHBOARD_ID_URL = exports.API_PROJECT_ROBOT_DASHBOARD_URL = exports.API_PROJECT_STREAM_CALLSIGN_URL = exports.API_PROJECT_STREAM_DATA_URL = exports.API_PROJECT_STREAM_ID_URL = void 0;
6
+ exports.API_PROJECT_ROBOT_TAG_URL = exports.API_PROJECT_PROFILE_TAG_URL = exports.API_PROJECT_PROFILE_TAGS_URL = exports.API_PROJECT_TAG_ROBOTS_URL = exports.API_PROJECT_ROBOT_TAGS_URL = exports.API_DEVICE_CREDENTIALS_AUTH_URL = exports.API_DEVICE_CREDENTIALS_URL = exports.API_LINKED_PROJECT_URL = exports.API_PROJECT_WORKFLOW_IMPORT_URL = exports.API_PROJECT_WORKFLOW_EXPORT_URL = exports.API_PROJECT_WORKFLOW_AFFECTED_URL = exports.API_PROJECT_ROBOT_DEPLOYED_WORKFLOW_URL = exports.API_PROJECT_PROFILE_DEPLOYED_WORKFLOW_URL = exports.API_PROJECT_ROBOT_NO_PROFILE_DEPLOYMENTS_URL = exports.API_PROJECT_PROFILE_DEPLOYMENTS_URL = exports.API_PROJECT_ROBOT_DEPLOYMENTS_URL = exports.API_PROJECT_WORKFLOW_ASSET_ID_URL = exports.API_PROJECT_WORKFLOW_ASSET_URL = exports.API_PROJECT_WORKFLOW_ID_URL = exports.API_PROJECT_WORKFLOW_URL = exports.API_GRAPHS_TARGET_MEDIA_URL = exports.API_GRAPHS_ASSETS_URL = exports.API_GRAPHS_ASSETS_UPLOAD_URL = exports.API_GRAPHS_TARGETS_URL = exports.API_GRAPHS_TARGET_UPLOAD_URL = exports.API_GRAPHS_OBSERVATION_KEYS_URL = exports.API_GRAPHS_OBSERVATIONS_URL = void 0;
7
7
  exports.API_APPLICATION_AUTH_URL = 'https://{url}/applications/auth';
8
8
  exports.API_ADMIN_USER_INVITATION_URL = 'https://{url}/admin/users/invitations';
9
9
  exports.API_USER_URL = 'https://{url}/users';
@@ -137,6 +137,8 @@ exports.API_GRAPHS_MAPS_DEPLOYED_URL = 'https://{url}/graphs/projects/{projectId
137
137
  exports.API_GRAPHS_MAPS_UNION_URL = 'https://{url}/graphs/projects/{projectId}/maps/union';
138
138
  exports.API_GRAPHS_MAP_ID_URL = 'https://{url}/graphs/projects/{projectId}/maps/{mapId}';
139
139
  exports.API_GRAPHS_MAP_CONTENT_URL = 'https://{url}/graphs/projects/{projectId}/maps/{mapId}/content';
140
+ exports.API_GRAPHS_MAP_EXTERNAL_DATA_UPLOAD_URL = 'https://{url}/graphs/projects/{projectId}/maps/externaldata';
141
+ exports.API_GRAPHS_MAP_EXTERNAL_DATA_URL = 'https://{url}/graphs/projects/{projectId}/maps/externaldata/{hash}';
140
142
  exports.API_GRAPHS_MAP_METADATA_URL = 'https://{url}/graphs/projects/{projectId}/maps/{mapId}/metadata';
141
143
  exports.API_GRAPHS_MAP_NODES_ADD_URL = 'https://{url}/graphs/projects/{projectId}/maps/{mapId}/nodes/add';
142
144
  exports.API_GRAPHS_MAP_NODES_ADD_TRANSFORMABLE_URL = 'https://{url}/graphs/projects/{projectId}/maps/{mapId}/nodes/add/transformable';
@@ -24,3 +24,12 @@ export interface MapContentEdge {
24
24
  data: Record<string, unknown>;
25
25
  externalData?: Record<string, unknown>;
26
26
  }
27
+ /** What `PUT /graphs/projects/{projectId}/maps/externaldata` returns for stored bytes. */
28
+ export interface ExternalDataUploadResponse {
29
+ /** sha256 of the bytes: the `hash` a node's or edge's `externalData` entry names. */
30
+ hash: string;
31
+ /** How many bytes were stored. */
32
+ bytes: number;
33
+ /** The media type they were stored with. */
34
+ contentType: string;
35
+ }
@@ -16,6 +16,11 @@ interface RequestConfig {
16
16
  */
17
17
  responseType?: ResponseType;
18
18
  }
19
+ /**
20
+ * Bytes to send as a request body verbatim, rather than JSON-encoded. A view must sit on a plain
21
+ * ArrayBuffer, as fetch requires.
22
+ */
23
+ export type BinaryPayload = Blob | ArrayBuffer | ArrayBufferView<ArrayBuffer>;
19
24
  export declare abstract class BaseServiceAbstract {
20
25
  protected config: IRocosSDKConfig;
21
26
  protected logger: Logger;
@@ -4,6 +4,11 @@ exports.BaseServiceAbstract = void 0;
4
4
  const models_1 = require("../models");
5
5
  const helpers_1 = require("../helpers");
6
6
  const RocosStore_1 = require("../store/RocosStore");
7
+ const isBinaryPayload = (payload) => {
8
+ if (typeof Blob !== 'undefined' && payload instanceof Blob)
9
+ return true;
10
+ return payload instanceof ArrayBuffer || ArrayBuffer.isView(payload);
11
+ };
7
12
  class BaseServiceAbstract {
8
13
  constructor(config) {
9
14
  this.config = config;
@@ -40,6 +45,10 @@ class BaseServiceAbstract {
40
45
  if (typeof FormData !== 'undefined' && payload instanceof FormData) {
41
46
  requestConfig.body = payload;
42
47
  }
48
+ else if (isBinaryPayload(payload)) {
49
+ // Raw bytes go up as-is; the caller names their media type in config.headers.
50
+ requestConfig.body = payload;
51
+ }
43
52
  else if (payload) {
44
53
  requestConfig.body = JSON.stringify(payload);
45
54
  requestConfig.headers = { ...requestConfig.headers, 'Content-Type': 'application/json' };
@@ -2,8 +2,8 @@ import { AddEdgeRequest, AddEdgeResponse, AddTransformEdgeRequest } from '../mod
2
2
  import { AddNodeRequest, AddNodeResponse, AddTransformableNodeRequest } from '../models/maps/MapNode';
3
3
  import { AddPanoramaRequest, AddPanoramaResponse, CreateObservation, Observation } from '../models/maps/Panorama';
4
4
  import { AppendPathPointsResponse, AppendToPathRequest, AppendTransformablePointsRequest, ListPathsFilter, MapPath, ReplacePathRequest } from '../models/maps/MapPath';
5
- import { Asset, IBaseService, IRocosSDKConfig, Map, MapContent, RocosError } from '../models';
6
- import { BaseServiceAbstract } from './BaseServiceAbstract';
5
+ import { Asset, ExternalDataUploadResponse, IBaseService, IRocosSDKConfig, Map, MapContent, RocosError } from '../models';
6
+ import { BaseServiceAbstract, BinaryPayload } from './BaseServiceAbstract';
7
7
  /**
8
8
  * Maps service for managing robot maps in the cloud and on robots
9
9
  */
@@ -105,6 +105,32 @@ export declare class MapService extends BaseServiceAbstract implements IBaseServ
105
105
  * @param content Canonical map content to write
106
106
  */
107
107
  updateContent(projectId: string, mapId: string, content: MapContent): Promise<void>;
108
+ /**
109
+ * Downloads the bytes behind a map node's or edge's `externalData` entry.
110
+ *
111
+ * The entry names the bytes by `hash`; giraffe answers with a redirect to a
112
+ * signed download URL, which `fetch` follows. The returned blob carries the
113
+ * content type the bytes were stored with. An entry whose `encoding` is
114
+ * `b64` holds base64 text, which the caller decodes.
115
+ *
116
+ * @param projectId Project ID
117
+ * @param hash The entry's `hash`
118
+ */
119
+ getExternalData(projectId: string, hash: string): Promise<Blob>;
120
+ /**
121
+ * Stores bytes as map external data, for a node's or edge's `externalData`
122
+ * entry to name by the returned `hash`.
123
+ *
124
+ * Giraffe hashes the bytes (sha256) and keeps them in the project's map-asset
125
+ * store under that hash with the given media type, which is what
126
+ * {@link getExternalData} later serves. Storing the same bytes twice is
127
+ * harmless. The server caps one item at 64 MiB.
128
+ *
129
+ * @param projectId Project ID
130
+ * @param data The bytes to store
131
+ * @param contentType Their media type; `application/octet-stream` when omitted
132
+ */
133
+ putExternalData(projectId: string, data: BinaryPayload, contentType?: string): Promise<ExternalDataUploadResponse>;
108
134
  /**
109
135
  * Begins uploading a map from the agent
110
136
  *
@@ -154,6 +154,43 @@ class MapService extends BaseServiceAbstract_1.BaseServiceAbstract {
154
154
  mapId,
155
155
  }, this.config.insecure), content, 'Failed to update map content.');
156
156
  }
157
+ /**
158
+ * Downloads the bytes behind a map node's or edge's `externalData` entry.
159
+ *
160
+ * The entry names the bytes by `hash`; giraffe answers with a redirect to a
161
+ * signed download URL, which `fetch` follows. The returned blob carries the
162
+ * content type the bytes were stored with. An entry whose `encoding` is
163
+ * `b64` holds base64 text, which the caller decodes.
164
+ *
165
+ * @param projectId Project ID
166
+ * @param hash The entry's `hash`
167
+ */
168
+ async getExternalData(projectId, hash) {
169
+ return this.callGet((0, formatServiceUrl_1.formatServiceUrl)(api_1.API_GRAPHS_MAP_EXTERNAL_DATA_URL, {
170
+ url: this.config.url,
171
+ projectId,
172
+ hash: encodeURIComponent(hash),
173
+ }, this.config.insecure), 'Failed to get map external data.', undefined, { responseType: 'blob' });
174
+ }
175
+ /**
176
+ * Stores bytes as map external data, for a node's or edge's `externalData`
177
+ * entry to name by the returned `hash`.
178
+ *
179
+ * Giraffe hashes the bytes (sha256) and keeps them in the project's map-asset
180
+ * store under that hash with the given media type, which is what
181
+ * {@link getExternalData} later serves. Storing the same bytes twice is
182
+ * harmless. The server caps one item at 64 MiB.
183
+ *
184
+ * @param projectId Project ID
185
+ * @param data The bytes to store
186
+ * @param contentType Their media type; `application/octet-stream` when omitted
187
+ */
188
+ async putExternalData(projectId, data, contentType = 'application/octet-stream') {
189
+ return this.callPut((0, formatServiceUrl_1.formatServiceUrl)(api_1.API_GRAPHS_MAP_EXTERNAL_DATA_UPLOAD_URL, {
190
+ url: this.config.url,
191
+ projectId,
192
+ }, this.config.insecure), data, 'Failed to store map external data.', { headers: { 'Content-Type': contentType } });
193
+ }
157
194
  /**
158
195
  * Begins uploading a map from the agent
159
196
  *
@@ -1,5 +1,6 @@
1
1
  export * from './AssetStorageService';
2
2
  export * from './AuthService';
3
+ export type { BinaryPayload } from './BaseServiceAbstract';
3
4
  export * from './CallerService';
4
5
  export * from './CommandService';
5
6
  export * from './ConfigGroupService';
@@ -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";
@@ -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
  *
@@ -1,5 +1,6 @@
1
1
  export * from './AssetStorageService';
2
2
  export * from './AuthService';
3
+ export type { BinaryPayload } from './BaseServiceAbstract';
3
4
  export * from './CallerService';
4
5
  export * from './CommandService';
5
6
  export * from './ConfigGroupService';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dronedeploy/rocos-js-sdk",
3
- "version": "4.5.0",
3
+ "version": "4.5.1",
4
4
  "description": "Javascript SDK for rocos",
5
5
  "main": "cjs/index.js",
6
6
  "module": "esm/index.js",