@dronedeploy/rocos-js-sdk 3.0.1-alpha.14 → 3.0.1-alpha.16
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/IRocosSDK.d.ts +2 -2
- package/cjs/RocosSDK.d.ts +7 -6
- package/cjs/RocosSDK.js +11 -10
- package/cjs/constants/api.d.ts +4 -6
- package/cjs/constants/api.js +6 -8
- package/cjs/models/RocosError.d.ts +1 -0
- package/cjs/models/RocosError.js +1 -0
- package/cjs/models/ServiceEnum.d.ts +2 -1
- package/cjs/models/ServiceEnum.js +1 -0
- package/cjs/models/TelemetryStatus.d.ts +12 -0
- package/cjs/models/TelemetryStatus.js +17 -0
- package/cjs/models/Token.d.ts +2 -2
- package/cjs/models/Token.js +5 -5
- package/cjs/models/device-credentials/DeviceCredentials.d.ts +46 -0
- package/cjs/models/device-credentials/DeviceCredentials.js +2 -0
- package/cjs/models/index.d.ts +1 -1
- package/cjs/models/index.js +1 -1
- package/cjs/node/RocosSDKNode.d.ts +2 -1
- package/cjs/node/RocosSDKNode.js +6 -3
- package/cjs/services/DeviceCredentialsService.d.ts +15 -0
- package/cjs/services/DeviceCredentialsService.js +50 -0
- package/cjs/services/MapService.d.ts +1 -1
- package/cjs/services/MapService.js +1 -1
- package/cjs/services/ProfileService.d.ts +2 -1
- package/cjs/services/ProfileService.js +9 -3
- package/cjs/services/TelemetryService.d.ts +10 -1
- package/cjs/services/TelemetryService.js +27 -5
- package/cjs/services/index.d.ts +1 -1
- package/cjs/services/index.js +1 -1
- package/esm/IRocosSDK.d.ts +2 -2
- package/esm/RocosSDK.d.ts +7 -6
- package/esm/RocosSDK.js +12 -11
- package/esm/constants/api.d.ts +4 -6
- package/esm/constants/api.js +4 -6
- package/esm/models/RocosError.d.ts +1 -0
- package/esm/models/RocosError.js +1 -0
- package/esm/models/ServiceEnum.d.ts +2 -1
- package/esm/models/ServiceEnum.js +1 -0
- package/esm/models/TelemetryStatus.d.ts +12 -0
- package/esm/models/TelemetryStatus.js +14 -0
- package/esm/models/Token.d.ts +2 -2
- package/esm/models/Token.js +5 -5
- package/esm/models/device-credentials/DeviceCredentials.d.ts +46 -0
- package/esm/models/device-credentials/DeviceCredentials.js +1 -0
- package/esm/models/index.d.ts +1 -1
- package/esm/models/index.js +1 -1
- package/esm/node/RocosSDKNode.d.ts +2 -1
- package/esm/node/RocosSDKNode.js +7 -4
- package/esm/services/DeviceCredentialsService.d.ts +15 -0
- package/esm/services/DeviceCredentialsService.js +46 -0
- package/esm/services/MapService.d.ts +1 -1
- package/esm/services/MapService.js +1 -1
- package/esm/services/ProfileService.d.ts +2 -1
- package/esm/services/ProfileService.js +9 -3
- package/esm/services/TelemetryService.d.ts +10 -1
- package/esm/services/TelemetryService.js +28 -6
- package/esm/services/index.d.ts +1 -1
- package/esm/services/index.js +1 -1
- package/package.json +1 -2
- package/cjs/models/CallsignStatus.d.ts +0 -6
- package/cjs/models/CallsignStatus.js +0 -10
- package/cjs/services/FunctionService.d.ts +0 -68
- package/cjs/services/FunctionService.js +0 -103
- package/esm/models/CallsignStatus.d.ts +0 -6
- package/esm/models/CallsignStatus.js +0 -7
- package/esm/services/FunctionService.d.ts +0 -68
- package/esm/services/FunctionService.js +0 -99
@@ -1,5 +1,5 @@
|
|
1
1
|
import { Observable } from 'rxjs';
|
2
|
-
import { CallsignStatus, IRocosSDKConfig, IRocosTelemetryMessage, IStreamStatusMessage, ITelemetryStream, ITelemetryStreamConfig, ITelemetrySubscriptionParams, ITelemetrySubscriptions } from '../models';
|
2
|
+
import { CallsignStatus, IRocosSDKConfig, IRocosTelemetryMessage, IStreamStatusMessage, ITelemetryStream, ITelemetryStreamConfig, ITelemetrySubscriptionParams, ITelemetrySubscriptions, TelemetryMonitorStatus } from '../models';
|
3
3
|
import { BaseStreamService } from './BaseStreamService';
|
4
4
|
export declare class TelemetryService extends BaseStreamService<ITelemetryStream, ITelemetryStreamConfig> {
|
5
5
|
private statusSubscription;
|
@@ -34,6 +34,15 @@ export declare class TelemetryService extends BaseStreamService<ITelemetryStream
|
|
34
34
|
* @param intervalMs optionally override the interval to check for heartbeats (in ms). Default 2000ms
|
35
35
|
*/
|
36
36
|
getRobotStatusChanges(projectId: string, callsign: string, heartbeatTimeoutMs?: number, intervalMs?: number): Observable<CallsignStatus>;
|
37
|
+
/**
|
38
|
+
* Subscribes to the given telemetry and checks we receive one at least emission every `heartbeatTimeoutMs` (default 5s)
|
39
|
+
* @param projectId
|
40
|
+
* @param callsign
|
41
|
+
* @param source the telemetry source to monitor
|
42
|
+
* @param heartbeatTimeoutMs optionally override the deadline for telemetry emissions (in ms). Default 5000ms
|
43
|
+
* @param intervalMs optionally override the interval to check for telemetry emissions (in ms). Default 2000ms
|
44
|
+
*/
|
45
|
+
monitorTelemetryWithTimeout(projectId: string, callsign: string, source: string, heartbeatTimeoutMs?: number, intervalMs?: number): Observable<TelemetryMonitorStatus>;
|
37
46
|
protected initStream(stream: ITelemetryStream): Promise<void>;
|
38
47
|
private buildScope;
|
39
48
|
private createStream;
|
@@ -1,5 +1,5 @@
|
|
1
1
|
import { BehaviorSubject, catchError, combineLatest, distinctUntilChanged, from, interval, map, mergeAll, of, startWith, } from 'rxjs';
|
2
|
-
import { CallsignStatus, CallsignsLookup, CallsignsLookupType, RocosError, SubscriberStatusEnum, errorCodes, } from '../models';
|
2
|
+
import { CallsignStatus, CallsignsLookup, CallsignsLookupType, RocosError, TelemetryMonitorStatus, SubscriberStatusEnum, errorCodes, } from '../models';
|
3
3
|
import { filter, finalize } from 'rxjs/operators';
|
4
4
|
import { BaseStreamService } from './BaseStreamService';
|
5
5
|
import { IDENTIFIER_NAME_TELEMETRY } from '../constants/identifier';
|
@@ -95,23 +95,45 @@ export class TelemetryService extends BaseStreamService {
|
|
95
95
|
* @param intervalMs optionally override the interval to check for heartbeats (in ms). Default 2000ms
|
96
96
|
*/
|
97
97
|
getRobotStatusChanges(projectId, callsign, heartbeatTimeoutMs = HEARTBEAT_TIMEOUT, intervalMs = 2000) {
|
98
|
+
return this.monitorTelemetryWithTimeout(projectId, callsign, HEARTBEAT_SOURCE, heartbeatTimeoutMs, intervalMs).pipe(map((status) => {
|
99
|
+
switch (status) {
|
100
|
+
case TelemetryMonitorStatus.CONNECTED:
|
101
|
+
return CallsignStatus.ONLINE;
|
102
|
+
case TelemetryMonitorStatus.DISCONNECTED:
|
103
|
+
return CallsignStatus.OFFLINE;
|
104
|
+
case TelemetryMonitorStatus.ERROR:
|
105
|
+
return CallsignStatus.ERROR;
|
106
|
+
default:
|
107
|
+
return CallsignStatus.UNKNOWN;
|
108
|
+
}
|
109
|
+
}));
|
110
|
+
}
|
111
|
+
/**
|
112
|
+
* Subscribes to the given telemetry and checks we receive one at least emission every `heartbeatTimeoutMs` (default 5s)
|
113
|
+
* @param projectId
|
114
|
+
* @param callsign
|
115
|
+
* @param source the telemetry source to monitor
|
116
|
+
* @param heartbeatTimeoutMs optionally override the deadline for telemetry emissions (in ms). Default 5000ms
|
117
|
+
* @param intervalMs optionally override the interval to check for telemetry emissions (in ms). Default 2000ms
|
118
|
+
*/
|
119
|
+
monitorTelemetryWithTimeout(projectId, callsign, source, heartbeatTimeoutMs = HEARTBEAT_TIMEOUT, intervalMs = 2000) {
|
98
120
|
const startedAt = Date.now();
|
99
121
|
const heartbeatTime$ = this.subscribe({
|
100
122
|
projectId,
|
101
|
-
sources: [
|
123
|
+
sources: [source],
|
102
124
|
callsigns: [callsign],
|
103
125
|
}).pipe(map(() => Date.now()));
|
104
126
|
return combineLatest([heartbeatTime$.pipe(startWith(startedAt)), interval(intervalMs)]).pipe(map(([lastHeartbeat, _]) => {
|
105
127
|
const now = Date.now();
|
106
128
|
// If we haven't received a heartbeat, but we've only just started
|
107
129
|
if (lastHeartbeat === startedAt && now - startedAt <= heartbeatTimeoutMs) {
|
108
|
-
return
|
130
|
+
return TelemetryMonitorStatus.UNKNOWN;
|
109
131
|
}
|
110
132
|
if (now - lastHeartbeat > heartbeatTimeoutMs) {
|
111
|
-
return
|
133
|
+
return TelemetryMonitorStatus.DISCONNECTED;
|
112
134
|
}
|
113
|
-
return
|
114
|
-
}), startWith(
|
135
|
+
return TelemetryMonitorStatus.CONNECTED;
|
136
|
+
}), startWith(TelemetryMonitorStatus.UNKNOWN), distinctUntilChanged(), catchError(() => of(TelemetryMonitorStatus.ERROR)));
|
115
137
|
}
|
116
138
|
async initStream(stream) {
|
117
139
|
await super.initStream(stream);
|
package/esm/services/index.d.ts
CHANGED
@@ -5,9 +5,9 @@ export * from './CommandService';
|
|
5
5
|
export * from './ConfigGroupService';
|
6
6
|
export * from './ControlService';
|
7
7
|
export * from './DashboardService';
|
8
|
+
export * from './DeviceCredentialsService';
|
8
9
|
export * from './EventService';
|
9
10
|
export * from './FileAccessorService';
|
10
|
-
export * from './FunctionService';
|
11
11
|
export * from './IntegrationService';
|
12
12
|
export * from './ProfileService';
|
13
13
|
export * from './ProjectService';
|
package/esm/services/index.js
CHANGED
@@ -5,9 +5,9 @@ export * from './CommandService';
|
|
5
5
|
export * from './ConfigGroupService';
|
6
6
|
export * from './ControlService';
|
7
7
|
export * from './DashboardService';
|
8
|
+
export * from './DeviceCredentialsService';
|
8
9
|
export * from './EventService';
|
9
10
|
export * from './FileAccessorService';
|
10
|
-
export * from './FunctionService';
|
11
11
|
export * from './IntegrationService';
|
12
12
|
export * from './ProfileService';
|
13
13
|
export * from './ProjectService';
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@dronedeploy/rocos-js-sdk",
|
3
|
-
"version": "3.0.1-alpha.
|
3
|
+
"version": "3.0.1-alpha.16",
|
4
4
|
"description": "Javascript SDK for rocos",
|
5
5
|
"main": "cjs/index.js",
|
6
6
|
"module": "esm/index.js",
|
@@ -23,7 +23,6 @@
|
|
23
23
|
"devDependencies": {},
|
24
24
|
"dependencies": {
|
25
25
|
"@grpc/grpc-js": "^1.7.1",
|
26
|
-
"@improbable-eng/grpc-web": "^0.14.0",
|
27
26
|
"@protobuf-ts/grpcweb-transport": "^2.9.1",
|
28
27
|
"@protobuf-ts/plugin": "^2.9.1",
|
29
28
|
"@protobuf-ts/runtime": "^2.9.1",
|
@@ -1,10 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.CallsignStatus = void 0;
|
4
|
-
var CallsignStatus;
|
5
|
-
(function (CallsignStatus) {
|
6
|
-
CallsignStatus["UNKNOWN"] = "unknown";
|
7
|
-
CallsignStatus["ONLINE"] = "online";
|
8
|
-
CallsignStatus["OFFLINE"] = "offline";
|
9
|
-
CallsignStatus["ERROR"] = "error";
|
10
|
-
})(CallsignStatus || (exports.CallsignStatus = CallsignStatus = {}));
|
@@ -1,68 +0,0 @@
|
|
1
|
-
import { RocosError } from '../models/RocosError';
|
2
|
-
import { BaseServiceAbstract } from './BaseServiceAbstract';
|
3
|
-
import { IBaseService } from '../models/IBaseService';
|
4
|
-
import { IExportDataQuery } from '../models/IExportDataQuery';
|
5
|
-
import { IFunctionConfig } from '../models/IFunctionConfig';
|
6
|
-
import { IRocosSDKConfig } from '../models/IRocosSDKConfig';
|
7
|
-
export declare class FunctionService extends BaseServiceAbstract implements IBaseService {
|
8
|
-
constructor(config: IRocosSDKConfig);
|
9
|
-
protected getError(e: Error): RocosError;
|
10
|
-
getStatus(): boolean;
|
11
|
-
/**
|
12
|
-
* Export data
|
13
|
-
*
|
14
|
-
* @param projectId - Project Id
|
15
|
-
* @param query - Payload {@link IExportDataQuery}
|
16
|
-
*/
|
17
|
-
exportJobs(projectId: string, query: IExportDataQuery): Promise<any>;
|
18
|
-
/**
|
19
|
-
* Create a function
|
20
|
-
*
|
21
|
-
* @param projectId - Project Id
|
22
|
-
* @param model - Payload {@link IFunctionConfig}
|
23
|
-
*/
|
24
|
-
create(projectId: string, model: IFunctionConfig): Promise<any>;
|
25
|
-
/**
|
26
|
-
* Get a functions
|
27
|
-
*
|
28
|
-
* @param projectId - Project Id
|
29
|
-
*/
|
30
|
-
list(projectId: string): Promise<any>;
|
31
|
-
/**
|
32
|
-
* Update a function
|
33
|
-
*
|
34
|
-
* @param projectId - Project Id
|
35
|
-
* @param functionId - Function Id
|
36
|
-
* @param model - Payload {@link IFunctionConfig}
|
37
|
-
*/
|
38
|
-
update(projectId: string, functionId: string, model: IFunctionConfig): Promise<any>;
|
39
|
-
/**
|
40
|
-
* Get function
|
41
|
-
*
|
42
|
-
* @param projectId - Project Id
|
43
|
-
* @param functionId - Function Id
|
44
|
-
*/
|
45
|
-
info(projectId: string, functionId: string): Promise<any>;
|
46
|
-
/**
|
47
|
-
* Delete function
|
48
|
-
*
|
49
|
-
* @param projectId - Project Id
|
50
|
-
* @param functionId - Function Id
|
51
|
-
*/
|
52
|
-
delete(projectId: string, functionId: string): Promise<any>;
|
53
|
-
/**
|
54
|
-
* Run a function
|
55
|
-
*
|
56
|
-
* @param projectId - Project Id
|
57
|
-
* @param functionId - Function Id
|
58
|
-
* @param body - Payload
|
59
|
-
*/
|
60
|
-
run(projectId: string, functionId: string, body?: any): Promise<any>;
|
61
|
-
/**
|
62
|
-
* Get function pods
|
63
|
-
*
|
64
|
-
* @param projectId - Project Id
|
65
|
-
* @param functionId - Function Id
|
66
|
-
*/
|
67
|
-
pods(projectId: string, functionId: string): Promise<any>;
|
68
|
-
}
|
@@ -1,103 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.FunctionService = void 0;
|
4
|
-
const api_1 = require("../constants/api");
|
5
|
-
const RocosError_1 = require("../models/RocosError");
|
6
|
-
const BaseServiceAbstract_1 = require("./BaseServiceAbstract");
|
7
|
-
const ExportDataQuery_1 = require("../models/ExportDataQuery");
|
8
|
-
const RocosLogger_1 = require("../logger/RocosLogger");
|
9
|
-
const formatServiceUrl_1 = require("../helpers/formatServiceUrl");
|
10
|
-
class FunctionService extends BaseServiceAbstract_1.BaseServiceAbstract {
|
11
|
-
constructor(config) {
|
12
|
-
super(config);
|
13
|
-
this.logger = RocosLogger_1.RocosLogger.getInstance(`FunctionService(${this.config.url})`);
|
14
|
-
}
|
15
|
-
getError(e) {
|
16
|
-
return new RocosError_1.RocosError(e, RocosError_1.errorCodes.FUNCTION_SERVICE_ERROR);
|
17
|
-
}
|
18
|
-
getStatus() {
|
19
|
-
return true;
|
20
|
-
}
|
21
|
-
/**
|
22
|
-
* Export data
|
23
|
-
*
|
24
|
-
* @param projectId - Project Id
|
25
|
-
* @param query - Payload {@link IExportDataQuery}
|
26
|
-
*/
|
27
|
-
// TODO: map the response object
|
28
|
-
async exportJobs(projectId, query) {
|
29
|
-
return this.callPost((0, formatServiceUrl_1.formatServiceUrl)(api_1.API_PROJECT_EXPORT_URL, { url: this.config.url, projectId }, this.config.insecure), new ExportDataQuery_1.ExportDataQuery(query).toJSON(), `Failed to export data for ${projectId}.`);
|
30
|
-
}
|
31
|
-
/**
|
32
|
-
* Create a function
|
33
|
-
*
|
34
|
-
* @param projectId - Project Id
|
35
|
-
* @param model - Payload {@link IFunctionConfig}
|
36
|
-
*/
|
37
|
-
// TODO: map the response object
|
38
|
-
async create(projectId, model) {
|
39
|
-
return this.callPost((0, formatServiceUrl_1.formatServiceUrl)(api_1.API_PROJECT_FUNCTION_URL, { url: this.config.url, projectId }, this.config.insecure), model, `Failed to create function for ${projectId}.`);
|
40
|
-
}
|
41
|
-
/**
|
42
|
-
* Get a functions
|
43
|
-
*
|
44
|
-
* @param projectId - Project Id
|
45
|
-
*/
|
46
|
-
// TODO: map the response object
|
47
|
-
async list(projectId) {
|
48
|
-
return this.callGet((0, formatServiceUrl_1.formatServiceUrl)(api_1.API_PROJECT_FUNCTION_URL, { url: this.config.url, projectId }, this.config.insecure), `Failed to get functions for ${projectId}.`);
|
49
|
-
}
|
50
|
-
/**
|
51
|
-
* Update a function
|
52
|
-
*
|
53
|
-
* @param projectId - Project Id
|
54
|
-
* @param functionId - Function Id
|
55
|
-
* @param model - Payload {@link IFunctionConfig}
|
56
|
-
*/
|
57
|
-
// TODO: map the response object
|
58
|
-
async update(projectId, functionId, model) {
|
59
|
-
return this.callPut((0, formatServiceUrl_1.formatServiceUrl)(api_1.API_PROJECT_FUNCTION_ID_URL, { url: this.config.url, projectId, functionId }, this.config.insecure), model, `Failed to update function for ${projectId}, functionId ${functionId}.`);
|
60
|
-
}
|
61
|
-
/**
|
62
|
-
* Get function
|
63
|
-
*
|
64
|
-
* @param projectId - Project Id
|
65
|
-
* @param functionId - Function Id
|
66
|
-
*/
|
67
|
-
// TODO: map the response object
|
68
|
-
async info(projectId, functionId) {
|
69
|
-
return this.callGet((0, formatServiceUrl_1.formatServiceUrl)(api_1.API_PROJECT_FUNCTION_ID_URL, { url: this.config.url, projectId, functionId }, this.config.insecure), `Failed to get function for ${projectId}, functionId ${functionId}.`);
|
70
|
-
}
|
71
|
-
/**
|
72
|
-
* Delete function
|
73
|
-
*
|
74
|
-
* @param projectId - Project Id
|
75
|
-
* @param functionId - Function Id
|
76
|
-
*/
|
77
|
-
// TODO: map the response object
|
78
|
-
async delete(projectId, functionId) {
|
79
|
-
return this.callDelete((0, formatServiceUrl_1.formatServiceUrl)(api_1.API_PROJECT_FUNCTION_ID_URL, { url: this.config.url, projectId, functionId }, this.config.insecure), `Failed to delete function for ${projectId}, functionId ${functionId}.`);
|
80
|
-
}
|
81
|
-
/**
|
82
|
-
* Run a function
|
83
|
-
*
|
84
|
-
* @param projectId - Project Id
|
85
|
-
* @param functionId - Function Id
|
86
|
-
* @param body - Payload
|
87
|
-
*/
|
88
|
-
// TODO: map the response object
|
89
|
-
async run(projectId, functionId, body = null) {
|
90
|
-
return this.callPost((0, formatServiceUrl_1.formatServiceUrl)(api_1.API_PROJECT_FUNCTION_RUN_URL, { url: this.config.url, projectId, functionId }, this.config.insecure), body, `Failed to run function for ${projectId}, functionId ${functionId}.`);
|
91
|
-
}
|
92
|
-
/**
|
93
|
-
* Get function pods
|
94
|
-
*
|
95
|
-
* @param projectId - Project Id
|
96
|
-
* @param functionId - Function Id
|
97
|
-
*/
|
98
|
-
// TODO: map the response object
|
99
|
-
async pods(projectId, functionId) {
|
100
|
-
return this.callGet((0, formatServiceUrl_1.formatServiceUrl)(api_1.API_PROJECT_FUNCTION_POD_URL, { url: this.config.url, projectId, functionId }, this.config.insecure), `Failed to ged function pods for ${projectId}, functionId ${functionId}.`);
|
101
|
-
}
|
102
|
-
}
|
103
|
-
exports.FunctionService = FunctionService;
|
@@ -1,68 +0,0 @@
|
|
1
|
-
import { RocosError } from '../models/RocosError';
|
2
|
-
import { BaseServiceAbstract } from './BaseServiceAbstract';
|
3
|
-
import { IBaseService } from '../models/IBaseService';
|
4
|
-
import { IExportDataQuery } from '../models/IExportDataQuery';
|
5
|
-
import { IFunctionConfig } from '../models/IFunctionConfig';
|
6
|
-
import { IRocosSDKConfig } from '../models/IRocosSDKConfig';
|
7
|
-
export declare class FunctionService extends BaseServiceAbstract implements IBaseService {
|
8
|
-
constructor(config: IRocosSDKConfig);
|
9
|
-
protected getError(e: Error): RocosError;
|
10
|
-
getStatus(): boolean;
|
11
|
-
/**
|
12
|
-
* Export data
|
13
|
-
*
|
14
|
-
* @param projectId - Project Id
|
15
|
-
* @param query - Payload {@link IExportDataQuery}
|
16
|
-
*/
|
17
|
-
exportJobs(projectId: string, query: IExportDataQuery): Promise<any>;
|
18
|
-
/**
|
19
|
-
* Create a function
|
20
|
-
*
|
21
|
-
* @param projectId - Project Id
|
22
|
-
* @param model - Payload {@link IFunctionConfig}
|
23
|
-
*/
|
24
|
-
create(projectId: string, model: IFunctionConfig): Promise<any>;
|
25
|
-
/**
|
26
|
-
* Get a functions
|
27
|
-
*
|
28
|
-
* @param projectId - Project Id
|
29
|
-
*/
|
30
|
-
list(projectId: string): Promise<any>;
|
31
|
-
/**
|
32
|
-
* Update a function
|
33
|
-
*
|
34
|
-
* @param projectId - Project Id
|
35
|
-
* @param functionId - Function Id
|
36
|
-
* @param model - Payload {@link IFunctionConfig}
|
37
|
-
*/
|
38
|
-
update(projectId: string, functionId: string, model: IFunctionConfig): Promise<any>;
|
39
|
-
/**
|
40
|
-
* Get function
|
41
|
-
*
|
42
|
-
* @param projectId - Project Id
|
43
|
-
* @param functionId - Function Id
|
44
|
-
*/
|
45
|
-
info(projectId: string, functionId: string): Promise<any>;
|
46
|
-
/**
|
47
|
-
* Delete function
|
48
|
-
*
|
49
|
-
* @param projectId - Project Id
|
50
|
-
* @param functionId - Function Id
|
51
|
-
*/
|
52
|
-
delete(projectId: string, functionId: string): Promise<any>;
|
53
|
-
/**
|
54
|
-
* Run a function
|
55
|
-
*
|
56
|
-
* @param projectId - Project Id
|
57
|
-
* @param functionId - Function Id
|
58
|
-
* @param body - Payload
|
59
|
-
*/
|
60
|
-
run(projectId: string, functionId: string, body?: any): Promise<any>;
|
61
|
-
/**
|
62
|
-
* Get function pods
|
63
|
-
*
|
64
|
-
* @param projectId - Project Id
|
65
|
-
* @param functionId - Function Id
|
66
|
-
*/
|
67
|
-
pods(projectId: string, functionId: string): Promise<any>;
|
68
|
-
}
|
@@ -1,99 +0,0 @@
|
|
1
|
-
import { API_PROJECT_EXPORT_URL, API_PROJECT_FUNCTION_ID_URL, API_PROJECT_FUNCTION_POD_URL, API_PROJECT_FUNCTION_RUN_URL, API_PROJECT_FUNCTION_URL, } from '../constants/api';
|
2
|
-
import { RocosError, errorCodes } from '../models/RocosError';
|
3
|
-
import { BaseServiceAbstract } from './BaseServiceAbstract';
|
4
|
-
import { ExportDataQuery } from '../models/ExportDataQuery';
|
5
|
-
import { RocosLogger } from '../logger/RocosLogger';
|
6
|
-
import { formatServiceUrl } from '../helpers/formatServiceUrl';
|
7
|
-
export class FunctionService extends BaseServiceAbstract {
|
8
|
-
constructor(config) {
|
9
|
-
super(config);
|
10
|
-
this.logger = RocosLogger.getInstance(`FunctionService(${this.config.url})`);
|
11
|
-
}
|
12
|
-
getError(e) {
|
13
|
-
return new RocosError(e, errorCodes.FUNCTION_SERVICE_ERROR);
|
14
|
-
}
|
15
|
-
getStatus() {
|
16
|
-
return true;
|
17
|
-
}
|
18
|
-
/**
|
19
|
-
* Export data
|
20
|
-
*
|
21
|
-
* @param projectId - Project Id
|
22
|
-
* @param query - Payload {@link IExportDataQuery}
|
23
|
-
*/
|
24
|
-
// TODO: map the response object
|
25
|
-
async exportJobs(projectId, query) {
|
26
|
-
return this.callPost(formatServiceUrl(API_PROJECT_EXPORT_URL, { url: this.config.url, projectId }, this.config.insecure), new ExportDataQuery(query).toJSON(), `Failed to export data for ${projectId}.`);
|
27
|
-
}
|
28
|
-
/**
|
29
|
-
* Create a function
|
30
|
-
*
|
31
|
-
* @param projectId - Project Id
|
32
|
-
* @param model - Payload {@link IFunctionConfig}
|
33
|
-
*/
|
34
|
-
// TODO: map the response object
|
35
|
-
async create(projectId, model) {
|
36
|
-
return this.callPost(formatServiceUrl(API_PROJECT_FUNCTION_URL, { url: this.config.url, projectId }, this.config.insecure), model, `Failed to create function for ${projectId}.`);
|
37
|
-
}
|
38
|
-
/**
|
39
|
-
* Get a functions
|
40
|
-
*
|
41
|
-
* @param projectId - Project Id
|
42
|
-
*/
|
43
|
-
// TODO: map the response object
|
44
|
-
async list(projectId) {
|
45
|
-
return this.callGet(formatServiceUrl(API_PROJECT_FUNCTION_URL, { url: this.config.url, projectId }, this.config.insecure), `Failed to get functions for ${projectId}.`);
|
46
|
-
}
|
47
|
-
/**
|
48
|
-
* Update a function
|
49
|
-
*
|
50
|
-
* @param projectId - Project Id
|
51
|
-
* @param functionId - Function Id
|
52
|
-
* @param model - Payload {@link IFunctionConfig}
|
53
|
-
*/
|
54
|
-
// TODO: map the response object
|
55
|
-
async update(projectId, functionId, model) {
|
56
|
-
return this.callPut(formatServiceUrl(API_PROJECT_FUNCTION_ID_URL, { url: this.config.url, projectId, functionId }, this.config.insecure), model, `Failed to update function for ${projectId}, functionId ${functionId}.`);
|
57
|
-
}
|
58
|
-
/**
|
59
|
-
* Get function
|
60
|
-
*
|
61
|
-
* @param projectId - Project Id
|
62
|
-
* @param functionId - Function Id
|
63
|
-
*/
|
64
|
-
// TODO: map the response object
|
65
|
-
async info(projectId, functionId) {
|
66
|
-
return this.callGet(formatServiceUrl(API_PROJECT_FUNCTION_ID_URL, { url: this.config.url, projectId, functionId }, this.config.insecure), `Failed to get function for ${projectId}, functionId ${functionId}.`);
|
67
|
-
}
|
68
|
-
/**
|
69
|
-
* Delete function
|
70
|
-
*
|
71
|
-
* @param projectId - Project Id
|
72
|
-
* @param functionId - Function Id
|
73
|
-
*/
|
74
|
-
// TODO: map the response object
|
75
|
-
async delete(projectId, functionId) {
|
76
|
-
return this.callDelete(formatServiceUrl(API_PROJECT_FUNCTION_ID_URL, { url: this.config.url, projectId, functionId }, this.config.insecure), `Failed to delete function for ${projectId}, functionId ${functionId}.`);
|
77
|
-
}
|
78
|
-
/**
|
79
|
-
* Run a function
|
80
|
-
*
|
81
|
-
* @param projectId - Project Id
|
82
|
-
* @param functionId - Function Id
|
83
|
-
* @param body - Payload
|
84
|
-
*/
|
85
|
-
// TODO: map the response object
|
86
|
-
async run(projectId, functionId, body = null) {
|
87
|
-
return this.callPost(formatServiceUrl(API_PROJECT_FUNCTION_RUN_URL, { url: this.config.url, projectId, functionId }, this.config.insecure), body, `Failed to run function for ${projectId}, functionId ${functionId}.`);
|
88
|
-
}
|
89
|
-
/**
|
90
|
-
* Get function pods
|
91
|
-
*
|
92
|
-
* @param projectId - Project Id
|
93
|
-
* @param functionId - Function Id
|
94
|
-
*/
|
95
|
-
// TODO: map the response object
|
96
|
-
async pods(projectId, functionId) {
|
97
|
-
return this.callGet(formatServiceUrl(API_PROJECT_FUNCTION_POD_URL, { url: this.config.url, projectId, functionId }, this.config.insecure), `Failed to ged function pods for ${projectId}, functionId ${functionId}.`);
|
98
|
-
}
|
99
|
-
}
|