@dronedeploy/rocos-js-sdk 1.0.0-alpha-2 → 3.0.0-alpha.19

Sign up to get free protection for your applications and to get access to all the features.
Files changed (99) hide show
  1. package/IRocosSDK.d.ts +3 -26
  2. package/RocosSDK.d.ts +6 -1
  3. package/RocosSDK.js +11 -1
  4. package/api/streams/caller/CallerStreamAbstract.js +1 -1
  5. package/api/streams/command/CommandStreamAbstract.js +1 -1
  6. package/api/streams/search/SearchStreamAbstract.js +2 -2
  7. package/constants/api.d.ts +9 -5
  8. package/constants/api.js +9 -5
  9. package/grpc/conker_pb.grpc-client.js +1 -1
  10. package/grpc/conker_pb.js +1 -1
  11. package/grpc/filagree_pb.d.ts +5 -5
  12. package/grpc/filagree_pb.grpc-client.js +1 -1
  13. package/grpc/filagree_pb.js +6 -6
  14. package/grpc/google/protobuf/descriptor_pb.d.ts +2 -2
  15. package/grpc/google/protobuf/descriptor_pb.js +4 -4
  16. package/grpc/google/protobuf/empty_pb.js +1 -1
  17. package/grpc/pigeon_pb.grpc-client.js +1 -1
  18. package/grpc/pigeon_pb.js +1 -1
  19. package/grpc/rambo.uri.v1_pb.js +1 -1
  20. package/grpc/rambo.v1_pb.d.ts +1 -1
  21. package/grpc/rambo.v1_pb.grpc-client.js +1 -1
  22. package/grpc/rambo.v1_pb.js +2 -2
  23. package/grpc/serviette.uri.v1_pb.js +1 -1
  24. package/grpc/serviette.v1_pb.d.ts +2 -2
  25. package/grpc/serviette.v1_pb.grpc-client.js +1 -1
  26. package/grpc/serviette.v1_pb.js +3 -3
  27. package/grpc/slowlane_pb.d.ts +4 -4
  28. package/grpc/slowlane_pb.grpc-client.js +1 -1
  29. package/grpc/slowlane_pb.js +5 -5
  30. package/grpc/teletubby_pb.d.ts +2 -2
  31. package/grpc/teletubby_pb.grpc-client.js +1 -1
  32. package/grpc/teletubby_pb.js +8 -8
  33. package/helpers/getURLSearchParams.d.ts +2 -0
  34. package/helpers/getURLSearchParams.js +9 -0
  35. package/helpers/getURLSearchParams.spec.d.ts +1 -0
  36. package/helpers/getURLSearchParams.spec.js +19 -0
  37. package/helpers/index.d.ts +2 -0
  38. package/helpers/index.js +2 -0
  39. package/helpers/nanosecondToMillisecond.d.ts +1 -1
  40. package/helpers/nanosecondToMillisecond.js +10 -4
  41. package/helpers/nanosecondToMillisecond.spec.d.ts +1 -0
  42. package/helpers/nanosecondToMillisecond.spec.js +20 -0
  43. package/helpers/websandbox/connection.d.ts +67 -0
  44. package/helpers/websandbox/connection.js +133 -0
  45. package/helpers/websandbox/frame/frame.d.ts +12 -0
  46. package/helpers/websandbox/frame/frame.js +22 -0
  47. package/helpers/websandbox/frame/frame.source.d.ts +2 -0
  48. package/helpers/websandbox/frame/frame.source.js +5 -0
  49. package/helpers/websandbox/frame/index.d.ts +2 -0
  50. package/helpers/websandbox/frame/index.js +2 -0
  51. package/helpers/websandbox/frame/worker/index.d.ts +2 -0
  52. package/helpers/websandbox/frame/worker/index.js +2 -0
  53. package/helpers/websandbox/frame/worker/manager.d.ts +11 -0
  54. package/helpers/websandbox/frame/worker/manager.js +67 -0
  55. package/helpers/websandbox/frame/worker/manager.spec.d.ts +4 -0
  56. package/helpers/websandbox/frame/worker/manager.spec.js +127 -0
  57. package/helpers/websandbox/frame/worker/types.d.ts +11 -0
  58. package/helpers/websandbox/frame/worker/types.js +1 -0
  59. package/helpers/websandbox/frame/worker/worker.d.ts +1 -0
  60. package/helpers/websandbox/frame/worker/worker.js +74 -0
  61. package/helpers/websandbox/frame/worker/worker.source.d.ts +2 -0
  62. package/helpers/websandbox/frame/worker/worker.source.js +4 -0
  63. package/helpers/websandbox/index.d.ts +2 -0
  64. package/helpers/websandbox/index.js +2 -0
  65. package/helpers/websandbox/sandbox.d.ts +57 -0
  66. package/helpers/websandbox/sandbox.js +175 -0
  67. package/helpers/websandbox/types.d.ts +13 -0
  68. package/helpers/websandbox/types.js +1 -0
  69. package/models/RocosError.d.ts +1 -0
  70. package/models/RocosError.js +1 -0
  71. package/models/ServiceEnum.d.ts +2 -1
  72. package/models/ServiceEnum.js +1 -0
  73. package/models/asset-storage/AssetModelItem.d.ts +3 -0
  74. package/models/index.d.ts +1 -0
  75. package/models/index.js +1 -0
  76. package/models/maps/Map.d.ts +1 -3
  77. package/models/maps/Panorama.d.ts +36 -0
  78. package/models/maps/Panorama.js +1 -0
  79. package/models/workflow/Workflow.d.ts +36 -0
  80. package/models/workflow/Workflow.js +1 -0
  81. package/node/RocosSDKNode.d.ts +6 -1
  82. package/node/RocosSDKNode.js +7 -0
  83. package/package.json +5 -3
  84. package/services/AssetStorageService.d.ts +18 -3
  85. package/services/AssetStorageService.js +28 -4
  86. package/services/BaseServiceAbstract.d.ts +1 -1
  87. package/services/BaseServiceAbstract.js +2 -6
  88. package/services/BaseStreamService.js +1 -1
  89. package/services/EvaluatorService.d.ts +11 -0
  90. package/services/EvaluatorService.js +28 -0
  91. package/services/MapService.d.ts +36 -3
  92. package/services/MapService.js +47 -4
  93. package/services/TelemetryService.d.ts +1 -0
  94. package/services/TelemetryService.js +13 -1
  95. package/services/TelemetryService.spec.js +2 -2
  96. package/services/WorkflowService.d.ts +25 -29
  97. package/services/WorkflowService.js +30 -62
  98. package/services/index.d.ts +1 -0
  99. package/services/index.js +1 -0
@@ -0,0 +1,74 @@
1
+ const WHITELIST = [
2
+ 'TEMPORARY',
3
+ 'PERSISTENT',
4
+ 'console',
5
+ 'self',
6
+ 'onmessage',
7
+ 'postMessage',
8
+ 'global',
9
+ 'allowed',
10
+ 'Array',
11
+ 'Boolean',
12
+ 'Date',
13
+ 'Function',
14
+ 'Number',
15
+ 'Object',
16
+ 'RegExp',
17
+ 'String',
18
+ 'Error',
19
+ 'EvalError',
20
+ 'RangeError',
21
+ 'ReferenceError',
22
+ 'SyntaxError',
23
+ 'TypeError',
24
+ 'URIError',
25
+ 'decodeURI',
26
+ 'decodeURIComponent',
27
+ 'encodeURI',
28
+ 'encodeURIComponent',
29
+ 'isFinite',
30
+ 'isNaN',
31
+ 'parseFloat',
32
+ 'parseInt',
33
+ 'Infinity',
34
+ 'JSON',
35
+ 'Math',
36
+ 'NaN',
37
+ 'undefined',
38
+ ];
39
+ const windowProps = Object.getOwnPropertyNames(self);
40
+ const protoProps = Object.getOwnPropertyNames(self.__proto__);
41
+ const props = [...windowProps, ...protoProps];
42
+ props.forEach((prop) => {
43
+ if (!WHITELIST.includes(prop)) {
44
+ Object.defineProperty(self, prop, {
45
+ get: () => {
46
+ throw new Error(`Security Exception: cannot access ${prop}`);
47
+ },
48
+ set: () => {
49
+ throw new Error(`Security Exception: cannot set ${prop}`);
50
+ },
51
+ configurable: false,
52
+ });
53
+ }
54
+ });
55
+ // Parses and calls function string with args
56
+ onmessage = (event) => {
57
+ let result;
58
+ let success = true;
59
+ try {
60
+ const fn = Function(event.data.contextVariable, `"use strict";return (${event.data.code});`);
61
+ result = fn(event.data.context);
62
+ }
63
+ catch (e) {
64
+ result = e;
65
+ success = false;
66
+ }
67
+ const message = {
68
+ id: event.data.id,
69
+ result,
70
+ success,
71
+ };
72
+ postMessage(message);
73
+ };
74
+ export {};
@@ -0,0 +1,2 @@
1
+ declare const source: string;
2
+ export default source;
@@ -0,0 +1,4 @@
1
+ // Auto-generated file
2
+ /* eslint-disable */
3
+ const source = `(()=>{"use strict";(()=>{const e=["TEMPORARY","PERSISTENT","console","self","onmessage","postMessage","global","allowed","Array","Boolean","Date","Function","Number","Object","RegExp","String","Error","EvalError","RangeError","ReferenceError","SyntaxError","TypeError","URIError","decodeURI","decodeURIComponent","encodeURI","encodeURIComponent","isFinite","isNaN","parseFloat","parseInt","Infinity","JSON","Math","NaN","undefined"];[...Object.getOwnPropertyNames(self),...Object.getOwnPropertyNames(self.__proto__)].forEach((r=>{e.includes(r)||Object.defineProperty(self,r,{get:()=>{throw new Error(\`Security Exception: cannot access \${r}\`)},set:()=>{throw new Error(\`Security Exception: cannot set \${r}\`)},configurable:!1})})),onmessage=e=>{let r,t=!0;try{r=Function(e.data.contextVariable,\`"use strict";return (\${e.data.code});\`)(e.data.context)}catch(e){r=e,t=!1}const o={id:e.data.id,result:r,success:t};postMessage(o)}})()})();`;
4
+ export default source;
@@ -0,0 +1,2 @@
1
+ import WebSandbox from './sandbox';
2
+ export { WebSandbox };
@@ -0,0 +1,2 @@
1
+ import WebSandbox from './sandbox';
2
+ export { WebSandbox };
@@ -0,0 +1,57 @@
1
+ export interface SandboxOptions extends Required<RunCodeOptions> {
2
+ /** The selector or element to append the iframe to */
3
+ frameContainer: string | Element;
4
+ /** Whether to enable verbose logging */
5
+ debugMode: boolean;
6
+ }
7
+ export interface RunCodeOptions {
8
+ /** The name of the variable to use for the context object */
9
+ contextVariable?: string;
10
+ timeout?: {
11
+ /** The minimum time to wait for a task to complete
12
+ *
13
+ * The worker will attempt to kill the task after this time.
14
+ */
15
+ minimumMs: number;
16
+ /** The maximum time to wait for a task to complete
17
+ *
18
+ * The sandbox will be destroyed and rebuilt after this time.
19
+ */
20
+ maximumMs: number;
21
+ };
22
+ abortSignal?: AbortSignal | null;
23
+ }
24
+ export declare const BaseOptions: SandboxOptions;
25
+ export interface SandboxMethods {
26
+ iframeInitialised: () => void;
27
+ }
28
+ /** A sandbox for running untrusted code in an iframe & embedded web worker.
29
+ *
30
+ * This is a wrapper around the iframe and web worker that provides a simple API for running code in the sandbox.
31
+ * It also provides a context object that can be used to pass data into the sandbox.
32
+ */
33
+ export default class WebSandbox {
34
+ private readonly options;
35
+ private frame;
36
+ private connection?;
37
+ private initialised;
38
+ private frameAbortController;
39
+ static new(options?: Partial<SandboxOptions>): Promise<WebSandbox>;
40
+ private constructor();
41
+ /** Runs code in the sandbox. Can be either a string or a function */
42
+ run<T = unknown>(code: string | (() => T), context?: unknown, options?: RunCodeOptions): Promise<T>;
43
+ /** Destroys the sandbox.
44
+ *
45
+ * This will remove the iframe from the DOM and remove the message listener.
46
+ */
47
+ destroy(): void;
48
+ private initialise;
49
+ private validateOptions;
50
+ private destroyAndRebuild;
51
+ private removeMessageListener;
52
+ private runFunction;
53
+ private runCode;
54
+ private promisifyAbortSignal;
55
+ private createFrame;
56
+ private prepareFrameContent;
57
+ }
@@ -0,0 +1,175 @@
1
+ import Connection from './connection';
2
+ import frameSource from './frame';
3
+ import { generateUUID } from '../generateUUID';
4
+ export const BaseOptions = {
5
+ frameContainer: 'body',
6
+ debugMode: false,
7
+ contextVariable: 'ctx',
8
+ timeout: {
9
+ minimumMs: 1000,
10
+ maximumMs: 1500,
11
+ },
12
+ abortSignal: null,
13
+ };
14
+ /** A sandbox for running untrusted code in an iframe & embedded web worker.
15
+ *
16
+ * This is a wrapper around the iframe and web worker that provides a simple API for running code in the sandbox.
17
+ * It also provides a context object that can be used to pass data into the sandbox.
18
+ */
19
+ export default class WebSandbox {
20
+ static async new(options = {}) {
21
+ const sandbox = new WebSandbox(options);
22
+ await sandbox.initialised;
23
+ return sandbox;
24
+ }
25
+ constructor(options) {
26
+ this.options = { ...BaseOptions, ...options };
27
+ this.frame = this.createFrame();
28
+ this.validateOptions(this.options);
29
+ this.initialised = this.initialise();
30
+ this.frameAbortController = new AbortController();
31
+ if (options.abortSignal) {
32
+ this.promisifyAbortSignal(options.abortSignal).catch(() => {
33
+ void this.destroyAndRebuild(this.frame.id);
34
+ });
35
+ }
36
+ }
37
+ /** Runs code in the sandbox. Can be either a string or a function */
38
+ async run(code, context, options) {
39
+ if (typeof code === 'function') {
40
+ return this.runFunction(code, context);
41
+ }
42
+ return this.runCode(code, context, options);
43
+ }
44
+ /** Destroys the sandbox.
45
+ *
46
+ * This will remove the iframe from the DOM and remove the message listener.
47
+ */
48
+ destroy() {
49
+ this.frameAbortController.abort();
50
+ this.frame.remove();
51
+ this.removeMessageListener();
52
+ }
53
+ initialise() {
54
+ return new Promise((resolve) => {
55
+ this.connection = new Connection('SANDBOX', this.frame.contentWindow.postMessage.bind(this.frame.contentWindow), {
56
+ iframeInitialised: () => resolve(),
57
+ }, (listener) => {
58
+ const sourceCheckListener = (event) => {
59
+ if (event.source !== this.frame.contentWindow) {
60
+ return;
61
+ }
62
+ return listener(event);
63
+ };
64
+ window.addEventListener('message', sourceCheckListener);
65
+ this.removeMessageListener = () => window.removeEventListener('message', sourceCheckListener);
66
+ }, { allowedSenderOrigin: 'null', debugMode: this.options.debugMode });
67
+ });
68
+ }
69
+ validateOptions(options) {
70
+ const minimumTimeout = options.timeout.minimumMs;
71
+ const maximumTimeout = options.timeout.maximumMs;
72
+ if (maximumTimeout < minimumTimeout) {
73
+ throw new Error(`maximum timeout (${maximumTimeout}ms) must be greater than or equal to minimum timeout (${minimumTimeout}ms)`);
74
+ }
75
+ if (minimumTimeout <= 0 || maximumTimeout <= 0) {
76
+ throw new Error('timeout values must be greater than 0');
77
+ }
78
+ if (maximumTimeout > 5000) {
79
+ throw new Error('maximum timeout must be less than or equal to 5000ms');
80
+ }
81
+ }
82
+ async destroyAndRebuild(frameId) {
83
+ if (this.frame.id !== frameId) {
84
+ return;
85
+ }
86
+ this.destroy();
87
+ this.frame = this.createFrame();
88
+ this.frameAbortController = new AbortController();
89
+ await this.initialise();
90
+ }
91
+ removeMessageListener() {
92
+ // replaced by constructor
93
+ }
94
+ async runFunction(fn, context, options) {
95
+ return this.runCode(`(${fn.toString()})()`, context, options);
96
+ }
97
+ async runCode(code, context, options) {
98
+ if (!this.connection) {
99
+ throw new Error('sandbox not initialised');
100
+ }
101
+ this.validateOptions({
102
+ ...this.options,
103
+ ...options,
104
+ });
105
+ const frameId = this.frame.id;
106
+ const timeout = this.promisifyAbortSignal(AbortSignal.timeout(options?.timeout?.maximumMs ?? this.options.timeout.maximumMs));
107
+ const frameAbortedSignal = this.promisifyAbortSignal(this.frameAbortController.signal);
108
+ const userAbortedSignal = options?.abortSignal ? this.promisifyAbortSignal(options.abortSignal) : null;
109
+ const taskId = generateUUID();
110
+ const task = this.connection.callRemoteMethod('startTask', {
111
+ id: taskId,
112
+ code,
113
+ context,
114
+ timeout: this.options.timeout.minimumMs,
115
+ contextVariable: options?.contextVariable ?? this.options.contextVariable,
116
+ });
117
+ const signals = [task, timeout, frameAbortedSignal, userAbortedSignal].filter((i) => i !== null);
118
+ return Promise.race(signals).catch(async (e) => {
119
+ if (e.name === 'TimeoutError') {
120
+ await this.destroyAndRebuild(frameId);
121
+ }
122
+ throw e;
123
+ });
124
+ }
125
+ promisifyAbortSignal(signal) {
126
+ return new Promise((_, reject) => {
127
+ // If the signal is already aborted, immediately throw in order to reject the promise.
128
+ if (signal.aborted) {
129
+ reject(signal.reason);
130
+ }
131
+ // Watch for 'abort' signals
132
+ signal.addEventListener('abort', () => {
133
+ // Stop the main operation
134
+ // Reject the promise with the abort reason.
135
+ reject(signal.reason);
136
+ });
137
+ });
138
+ }
139
+ createFrame() {
140
+ const containerSelector = this.options.frameContainer;
141
+ const container = typeof containerSelector === 'string' ? document.querySelector(containerSelector) : containerSelector;
142
+ if (!container) {
143
+ throw new Error('unable to find container for sandbox');
144
+ }
145
+ const iframe = document.createElement('iframe');
146
+ if (iframe.sandbox) {
147
+ iframe.sandbox.add('allow-scripts');
148
+ }
149
+ else {
150
+ iframe.setAttribute('sandbox', 'allow-scripts');
151
+ }
152
+ iframe.srcdoc = this.prepareFrameContent();
153
+ iframe.style.display = 'none';
154
+ iframe.id = generateUUID();
155
+ container.appendChild(iframe);
156
+ return iframe;
157
+ }
158
+ prepareFrameContent() {
159
+ let script = frameSource;
160
+ if (this.options.debugMode) {
161
+ script = `window.debugMode=true;${script}`;
162
+ }
163
+ return `
164
+ <!DOCTYPE html>
165
+ <html>
166
+ <head>
167
+ <meta charset="UTF-8">
168
+ <script>
169
+ ${script}
170
+ </script>
171
+ </head>
172
+ </html>
173
+ `;
174
+ }
175
+ }
@@ -0,0 +1,13 @@
1
+ type APIMethod = (...args: any[]) => unknown;
2
+ export type API = Map<string, APIMethod>;
3
+ export type APIDeclaration<T> = {
4
+ [K in keyof T]: T[K] extends APIMethod ? T[K] : never;
5
+ };
6
+ export interface Task {
7
+ id: string;
8
+ code: string;
9
+ context?: unknown;
10
+ timeout: number;
11
+ contextVariable?: string;
12
+ }
13
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -22,6 +22,7 @@ export declare const errorCodes: {
22
22
  SCHEDULE_SERVICE_ERROR: string;
23
23
  INTEGRATIONS_SERVICE_ERROR: string;
24
24
  MAPS_SERVICE_ERROR: string;
25
+ EVALUATOR_SERVICE_ERROR: string;
25
26
  };
26
27
  export declare class RocosError extends Error {
27
28
  code?: string;
@@ -22,6 +22,7 @@ export const errorCodes = {
22
22
  SCHEDULE_SERVICE_ERROR: 'SCHEDULE_SERVICE_ERROR',
23
23
  INTEGRATIONS_SERVICE_ERROR: 'INTEGRATIONS_SERVICE_ERROR',
24
24
  MAPS_SERVICE_ERROR: 'MAPS_SERVICE_ERROR',
25
+ EVALUATOR_SERVICE_ERROR: 'EVALUATOR_SERVICE_ERROR',
25
26
  };
26
27
  export class RocosError extends Error {
27
28
  constructor(err, code, statusCode) {
@@ -22,5 +22,6 @@ export declare enum ServiceEnum {
22
22
  SCHEDULE = "schedule",
23
23
  SPOT_PROVISIONER = "spot_provisioner",
24
24
  INTEGRATION = "integration",
25
- MAP = "map"
25
+ MAP = "map",
26
+ EVALUATOR = "evaluator"
26
27
  }
@@ -24,4 +24,5 @@ export var ServiceEnum;
24
24
  ServiceEnum["SPOT_PROVISIONER"] = "spot_provisioner";
25
25
  ServiceEnum["INTEGRATION"] = "integration";
26
26
  ServiceEnum["MAP"] = "map";
27
+ ServiceEnum["EVALUATOR"] = "evaluator";
27
28
  })(ServiceEnum || (ServiceEnum = {}));
@@ -9,6 +9,9 @@ export interface AssetItemModel {
9
9
  modifiedTime?: number;
10
10
  size?: number;
11
11
  }
12
+ export interface AssetItemWithObservationsModel extends AssetItemModel {
13
+ observationCount?: number;
14
+ }
12
15
  export interface AssetSyncDefinitionModel {
13
16
  path: string;
14
17
  enabled: boolean;
package/models/index.d.ts CHANGED
@@ -73,3 +73,4 @@ export * from './Token';
73
73
  export * from './types';
74
74
  export * from './Widget';
75
75
  export * from './WidgetLineGroup';
76
+ export * from './workflow/Workflow';
package/models/index.js CHANGED
@@ -73,3 +73,4 @@ export * from './Token';
73
73
  export * from './types';
74
74
  export * from './Widget';
75
75
  export * from './WidgetLineGroup';
76
+ export * from './workflow/Workflow';
@@ -1,13 +1,11 @@
1
1
  export interface Map {
2
2
  id: string;
3
- name: string;
4
3
  description: string;
5
4
  nodes: number;
6
5
  edges: number;
7
6
  sizeBytes: number;
8
7
  deployed: boolean;
8
+ deployedCount: number;
9
9
  isUploading: boolean;
10
10
  isInCloud: boolean;
11
- lastModifiedTimestamp?: number;
12
- modifiedBy?: string;
13
11
  }
@@ -0,0 +1,36 @@
1
+ export interface Position {
2
+ pitch: number;
3
+ yaw: number;
4
+ x?: number;
5
+ y?: number;
6
+ }
7
+ export interface Quaternion {
8
+ x: number;
9
+ y: number;
10
+ z: number;
11
+ w: number;
12
+ }
13
+ export interface Vector3 {
14
+ x: number;
15
+ y: number;
16
+ z: number;
17
+ }
18
+ export interface Observation {
19
+ panoramaID: string;
20
+ id?: string;
21
+ name?: string;
22
+ data?: Record<string, string>;
23
+ geometry: Position[];
24
+ center?: Position;
25
+ }
26
+ export interface Panorama {
27
+ transform: {
28
+ parent: string;
29
+ id: string;
30
+ rot: Quaternion;
31
+ pos: Vector3;
32
+ };
33
+ data: {
34
+ path: string;
35
+ };
36
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,36 @@
1
+ export type ResourceType = 'Manifest' | 'AgentGraph' | 'Javascript' | 'NodeDefinition';
2
+ export interface Resource {
3
+ type: ResourceType;
4
+ data: string;
5
+ contentLink: string;
6
+ hash: string;
7
+ link: string;
8
+ path: string;
9
+ size: number;
10
+ }
11
+ export interface Resources {
12
+ [key: string]: Resource;
13
+ }
14
+ export interface Author {
15
+ id: string;
16
+ name: string;
17
+ email: string;
18
+ }
19
+ export interface WorkflowBase {
20
+ flowId: string;
21
+ name: string;
22
+ description: string;
23
+ resources?: Resources;
24
+ type?: string;
25
+ }
26
+ export interface Workflow extends WorkflowBase {
27
+ id: string;
28
+ projectId: string;
29
+ createdBy: string;
30
+ updatedBy: string;
31
+ author: Author;
32
+ dateCreated: number;
33
+ dateUpdated: number;
34
+ latestVersion: string;
35
+ type: string;
36
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -1,4 +1,4 @@
1
- import { ScheduleService } from '../services';
1
+ import { EvaluatorService, ScheduleService } from '../services';
2
2
  import { CallerServiceNode } from '../services/CallerServiceNode';
3
3
  import { CommandServiceNode } from '../services/CommandServiceNode';
4
4
  import { ControlServiceNode } from '../services/ControlServiceNode';
@@ -39,4 +39,9 @@ export declare class RocosSDKNode extends RocosSDK {
39
39
  * @returns FileAccessorServiceNode
40
40
  */
41
41
  getFileAccessorService(): FileAccessorServiceNode;
42
+ /**
43
+ * Gets the evaluator service
44
+ * @returns EvaluatorServiceNode
45
+ */
46
+ getEvaluatorService(): EvaluatorService;
42
47
  }
@@ -140,4 +140,11 @@ export class RocosSDKNode extends RocosSDK {
140
140
  getFileAccessorService() {
141
141
  return this.getService(ServiceEnum.FILE_ACCESSOR);
142
142
  }
143
+ /**
144
+ * Gets the evaluator service
145
+ * @returns EvaluatorServiceNode
146
+ */
147
+ getEvaluatorService() {
148
+ throw new Error('Evaluator service is not supported in NodeJS');
149
+ }
143
150
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dronedeploy/rocos-js-sdk",
3
- "version": "1.0.0-alpha-2",
3
+ "version": "3.0.0-alpha.19",
4
4
  "description": "Javascript SDK for rocos",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -23,5 +23,7 @@
23
23
  "rxjs": "^6.6.6 || ^7.0.0"
24
24
  },
25
25
  "repository": {},
26
- "private": false
27
- }
26
+ "private": false,
27
+ "type": "module",
28
+ "sideEffects": false
29
+ }
@@ -1,4 +1,4 @@
1
- import { AssetItemModel, AssetSyncDefinitionModel, AssetSyncDefinitionsModel } from '../models';
1
+ import { AssetItemModel, AssetItemWithObservationsModel, AssetSyncDefinitionModel, AssetSyncDefinitionsModel } from '../models';
2
2
  import { RocosError } from '../models/RocosError';
3
3
  import { BaseServiceAbstract } from './BaseServiceAbstract';
4
4
  import { IBaseService } from '../models/IBaseService';
@@ -67,9 +67,24 @@ export declare class AssetStorageService extends BaseServiceAbstract implements
67
67
  * List assets for a mission
68
68
  *
69
69
  * @param projectId
70
- * @param dataUUID
70
+ * @param assetIdList
71
71
  */
72
- getMissionAsset(projectId: string, dataUUID: string): Promise<AssetItemModel>;
72
+ listMissionAssets(projectId: string, assetIdList: string[]): Promise<AssetItemModel[]>;
73
+ /**
74
+ * Get a single asset for a mission
75
+ *
76
+ * @param projectId
77
+ * @param assetId
78
+ */
79
+ getMissionAsset(projectId: string, assetId: string): Promise<AssetItemModel>;
80
+ /**
81
+ * Lists mapped assets
82
+ *
83
+ * @param projectId
84
+ * @param start Start date for the query (optional)
85
+ * @param end End date for the query (optional)
86
+ */
87
+ listMappedAssets(projectId: string, start?: Date, end?: Date): Promise<AssetItemWithObservationsModel[]>;
73
88
  /**
74
89
  * Set Robot Sync Definitions
75
90
  * @param projectId
@@ -1,4 +1,4 @@
1
- import { API_PROJECT_ASSET_PATH_URL, API_PROJECT_ASSET_PROFILES_SYNC_DEFINITION_PATH_URL, API_PROJECT_ASSET_ROBOTS_SYNC_DEFINITION_PATH_URL, API_PROJECT_ASSET_URL, API_PROJECT_FLOW_ASSET_PATH_URL, API_PROJECT_MISSION_ASSET_PATH_URL, API_PROJECT_ROBOT_ASSET_PATH_URL, } from '../constants/api';
1
+ import { API_PROJECT_ASSET_PATH_URL, API_PROJECT_ASSET_PROFILES_SYNC_DEFINITION_PATH_URL, API_PROJECT_ASSET_ROBOTS_SYNC_DEFINITION_PATH_URL, API_PROJECT_ASSET_URL, API_PROJECT_FLOW_ASSET_PATH_URL, API_PROJECT_MAPPED_ASSETS_PATH_URL, API_PROJECT_MISSION_ASSETS_PATH_URL, API_PROJECT_MISSION_ASSET_PATH_URL, API_PROJECT_ROBOT_ASSET_PATH_URL, } from '../constants/api';
2
2
  import { RocosError, errorCodes } from '../models/RocosError';
3
3
  import { BaseServiceAbstract } from './BaseServiceAbstract';
4
4
  import { RocosLogger } from '../logger/RocosLogger';
@@ -106,10 +106,34 @@ export class AssetStorageService extends BaseServiceAbstract {
106
106
  * List assets for a mission
107
107
  *
108
108
  * @param projectId
109
- * @param dataUUID
109
+ * @param assetIdList
110
110
  */
111
- async getMissionAsset(projectId, dataUUID) {
112
- return this.callGet(formatServiceUrl(API_PROJECT_MISSION_ASSET_PATH_URL, { url: this.config.url, projectId, dataUUID }, this.config.insecure), `Failed to get asset for ${projectId}, dataUUID ${dataUUID}.`, undefined);
111
+ async listMissionAssets(projectId, assetIdList) {
112
+ const searchParams = new URLSearchParams();
113
+ assetIdList.forEach((assetId) => searchParams.append('assetID', assetId));
114
+ return this.callGet(formatServiceUrl(API_PROJECT_MISSION_ASSETS_PATH_URL, { url: this.config.url, projectId }, this.config.insecure), `Failed to get asset for ${projectId}, assetIdList ${assetIdList}.`, searchParams);
115
+ }
116
+ /**
117
+ * Get a single asset for a mission
118
+ *
119
+ * @param projectId
120
+ * @param assetId
121
+ */
122
+ async getMissionAsset(projectId, assetId) {
123
+ return this.callGet(formatServiceUrl(API_PROJECT_MISSION_ASSET_PATH_URL, { url: this.config.url, projectId, assetId }, this.config.insecure), `Failed to get asset for ${projectId}, dataUUID ${assetId}.`, undefined);
124
+ }
125
+ /**
126
+ * Lists mapped assets
127
+ *
128
+ * @param projectId
129
+ * @param start Start date for the query (optional)
130
+ * @param end End date for the query (optional)
131
+ */
132
+ async listMappedAssets(projectId, start, end) {
133
+ return this.callGet(formatServiceUrl(API_PROJECT_MAPPED_ASSETS_PATH_URL, { url: this.config.url, projectId }, this.config.insecure), `Failed to list mapped assets for ${projectId}.`, {
134
+ start: start?.toISOString() ?? '',
135
+ end: end?.toISOString() ?? '',
136
+ });
113
137
  }
114
138
  /**
115
139
  * Set Robot Sync Definitions
@@ -1,6 +1,6 @@
1
1
  import { IRocosSDKConfig, RocosError } from '../models';
2
+ import { QueryParams } from '../helpers';
2
3
  import { Logger } from 'loglevel';
3
- type QueryParams = Record<string, string | number | boolean> | URLSearchParams;
4
4
  type ResponseType = 'json' | 'blob' | 'stream' | 'text' | 'raw';
5
5
  interface RequestConfig {
6
6
  /**
@@ -1,4 +1,5 @@
1
1
  import { RocosError } from '../models';
2
+ import { getURLSearchParams } from '../helpers';
2
3
  import { RocosStore } from '../store/RocosStore';
3
4
  class HttpError extends Error {
4
5
  constructor(response) {
@@ -26,12 +27,7 @@ export class BaseServiceAbstract {
26
27
  async call(url, method, options) {
27
28
  const { errorMessage, config, payload, params } = options;
28
29
  try {
29
- // change all params to string
30
- const stringParams = Object.entries(params ?? {}).reduce((acc, [key, value]) => {
31
- acc[key] = value.toString();
32
- return acc;
33
- }, {});
34
- const formattedUrl = params ? `${url}?${new URLSearchParams(stringParams)}` : url;
30
+ const formattedUrl = params ? `${url}?${getURLSearchParams(params)}` : url;
35
31
  const defaultHeaders = {};
36
32
  if (!config?.public) {
37
33
  const token = await RocosStore.getSDKInstance(this.config).getAuthService().getToken();
@@ -28,7 +28,7 @@ export class BaseStreamService {
28
28
  authService.startTokenRefreshChecker();
29
29
  }
30
30
  async createStreamFromConfig(identifier, config) {
31
- const identifierWithScope = StreamRegister.getIdentifier(identifier);
31
+ const identifierWithScope = StreamRegister.getIdentifier(identifier, config.scope);
32
32
  const streamRegister = StreamRegister.getInstance();
33
33
  let stream = streamRegister.getStream(identifierWithScope);
34
34
  let isNew = false;