attlaz-client 1.9.14 → 1.9.15
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.
|
@@ -20,6 +20,7 @@ class Trigger extends MetaDataAware_1.MetaDataAware {
|
|
|
20
20
|
this.arguments = {};
|
|
21
21
|
}
|
|
22
22
|
static parse(rawTrigger) {
|
|
23
|
+
console.log(rawTrigger);
|
|
23
24
|
const type = TriggerType_1.TriggerType.fromString(rawTrigger.type);
|
|
24
25
|
const data = rawTrigger.data;
|
|
25
26
|
const flowId = rawTrigger.flow;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { OAuthClient } from '../Http/OAuthClient';
|
|
2
|
-
import { DataResult } from '../Model/Result/DataResult';
|
|
3
2
|
import { CollectionResult } from '../Model/Result/CollectionResult';
|
|
4
3
|
import { ObjectResult } from '../Model/Result/ObjectResult';
|
|
5
4
|
export declare abstract class Endpoint {
|
|
6
5
|
protected httpClient: OAuthClient;
|
|
7
6
|
constructor(httpClient: OAuthClient);
|
|
7
|
+
private formatParameters;
|
|
8
|
+
private formatKey;
|
|
8
9
|
requestCollection<T>(action: string, parameters: any, parser: (input: any) => T, method?: string, signWithOauthToken?: boolean): Promise<CollectionResult<T>>;
|
|
9
10
|
requestObject<T>(action: string, parameters: any, parser: (input: any) => T, method?: string, signWithOauthToken?: boolean): Promise<ObjectResult<T>>;
|
|
10
|
-
request<T>(action: string, parameters?: any, method?: string, signWithOauthToken?: boolean): Promise<DataResult<T>>;
|
|
11
11
|
parseCollection<T>(rawData: object[], parser: (input: any) => T): T[];
|
|
12
12
|
}
|
package/dist/Service/Endpoint.js
CHANGED
|
@@ -1,17 +1,68 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Endpoint = void 0;
|
|
4
|
-
const DataResult_1 = require("../Model/Result/DataResult");
|
|
5
4
|
const CollectionResult_1 = require("../Model/Result/CollectionResult");
|
|
6
5
|
const ObjectResult_1 = require("../Model/Result/ObjectResult");
|
|
7
6
|
const HttpClient_1 = require("../Http/HttpClient");
|
|
8
7
|
const Utils_1 = require("../Utils");
|
|
9
8
|
const ObjectWrapper_1 = require("../Model/Result/ObjectWrapper");
|
|
9
|
+
const DataValueCollection_1 = require("../Model/DataValueCollection");
|
|
10
|
+
const JsonSerializable_1 = require("../Model/JsonSerializable");
|
|
10
11
|
class Endpoint {
|
|
11
12
|
constructor(httpClient) {
|
|
12
13
|
this.httpClient = httpClient;
|
|
13
14
|
}
|
|
15
|
+
formatParameters(data = null) {
|
|
16
|
+
if (data === null || data === undefined) {
|
|
17
|
+
return null;
|
|
18
|
+
}
|
|
19
|
+
if (Array.isArray(data)) {
|
|
20
|
+
const result = [];
|
|
21
|
+
for (const value of data) {
|
|
22
|
+
result.push(this.formatParameters(value));
|
|
23
|
+
}
|
|
24
|
+
return result;
|
|
25
|
+
}
|
|
26
|
+
// if (DateHelper.isDate(data)) {
|
|
27
|
+
// return DateHelper.toString(data);
|
|
28
|
+
// }
|
|
29
|
+
// tODo: this does not seem to work correclty
|
|
30
|
+
if (data instanceof JsonSerializable_1.JsonSerializable && 'jsonSerialize' in data) {
|
|
31
|
+
return data.jsonSerialize();
|
|
32
|
+
}
|
|
33
|
+
if (typeof data === 'object') {
|
|
34
|
+
if (
|
|
35
|
+
// data instanceof WorkspaceId ||
|
|
36
|
+
// data instanceof ProjectEnvironmentId ||
|
|
37
|
+
// data instanceof ProjectId ||
|
|
38
|
+
// data instanceof OrganisationId ||
|
|
39
|
+
// data instanceof FlowId ||
|
|
40
|
+
// data instanceof FlowRunId ||
|
|
41
|
+
// data instanceof UserId ||
|
|
42
|
+
// data instanceof DataCollectionResult ||
|
|
43
|
+
// data instanceof SuccessResult ||
|
|
44
|
+
data instanceof DataValueCollection_1.DataValueCollection) {
|
|
45
|
+
return this.formatParameters(data.jsonSerialize());
|
|
46
|
+
}
|
|
47
|
+
const result = {};
|
|
48
|
+
for (const [key, value] of Object.entries(data)) {
|
|
49
|
+
const formattedKey = this.formatKey(key);
|
|
50
|
+
result[formattedKey] = this.formatParameters(value);
|
|
51
|
+
}
|
|
52
|
+
return result;
|
|
53
|
+
}
|
|
54
|
+
return data;
|
|
55
|
+
}
|
|
56
|
+
formatKey(key) {
|
|
57
|
+
let formattedKey = key.replace(/([A-Z])/g, ' $1');
|
|
58
|
+
formattedKey = formattedKey.split(' ').join('_').toLowerCase();
|
|
59
|
+
if (formattedKey.endsWith('_id')) {
|
|
60
|
+
formattedKey = formattedKey.substring(0, formattedKey.length - '_id'.length);
|
|
61
|
+
}
|
|
62
|
+
return formattedKey;
|
|
63
|
+
}
|
|
14
64
|
async requestCollection(action, parameters = null, parser, method = 'GET', signWithOauthToken = true) {
|
|
65
|
+
parameters = this.formatParameters(parameters);
|
|
15
66
|
const requestResponse = await this.httpClient.request(action, parameters, method, signWithOauthToken);
|
|
16
67
|
const result = new CollectionResult_1.CollectionResult();
|
|
17
68
|
/**
|
|
@@ -32,6 +83,7 @@ class Endpoint {
|
|
|
32
83
|
return result;
|
|
33
84
|
}
|
|
34
85
|
async requestObject(action, parameters = null, parser, method = 'GET', signWithOauthToken = true) {
|
|
86
|
+
parameters = this.formatParameters(parameters);
|
|
35
87
|
const result = new ObjectResult_1.ObjectResult();
|
|
36
88
|
try {
|
|
37
89
|
let requestResponse = await this.httpClient.request(action, parameters, method, signWithOauthToken);
|
|
@@ -39,8 +91,8 @@ class Endpoint {
|
|
|
39
91
|
/**
|
|
40
92
|
* Parse errors
|
|
41
93
|
*/
|
|
42
|
-
// TODO: temporary check
|
|
43
|
-
if (requestResponse.hasOwnProperty('data') && requestResponse.data !== undefined) {
|
|
94
|
+
// TODO: temporary check until we know the API is fully upgraded
|
|
95
|
+
if ((requestResponse.hasOwnProperty('data') && !requestResponse.hasOwnProperty('id')) && requestResponse.data !== undefined) {
|
|
44
96
|
console.error('Response for object "' + action + '" seem to still use old "data" property', { requestResponse });
|
|
45
97
|
requestResponse = requestResponse.data;
|
|
46
98
|
}
|
|
@@ -57,10 +109,11 @@ class Endpoint {
|
|
|
57
109
|
return result;
|
|
58
110
|
}
|
|
59
111
|
;
|
|
60
|
-
async request(action, parameters = null, method = 'GET', signWithOauthToken = true) {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
112
|
+
// public async request<T>(action: string, parameters: any | null = null, method: string = 'GET', signWithOauthToken: boolean = true): Promise<DataResult<T>> {
|
|
113
|
+
// const result: any = await this.httpClient.request(action, parameters, method, signWithOauthToken);
|
|
114
|
+
//
|
|
115
|
+
// return DataResult.parse<T>(result);
|
|
116
|
+
// }
|
|
64
117
|
parseCollection(rawData, parser) {
|
|
65
118
|
const data = [];
|
|
66
119
|
if (!Array.isArray(rawData)) {
|
|
@@ -50,7 +50,7 @@ class FlowRunEndpoint extends Endpoint_1.Endpoint {
|
|
|
50
50
|
}
|
|
51
51
|
async getFlowRunSummary(flowRunId) {
|
|
52
52
|
try {
|
|
53
|
-
const result = await this.requestObject('/
|
|
53
|
+
const result = await this.requestObject('/flowruns/' + flowRunId + '/summaries', null, FlowRunSummary_1.FlowRunSummary.parse);
|
|
54
54
|
return result;
|
|
55
55
|
}
|
|
56
56
|
catch (error) {
|
|
@@ -25,7 +25,7 @@ class StorageEndpoint extends Endpoint_1.Endpoint {
|
|
|
25
25
|
let cmd = '/projectenvironments/' + projectEnvironmentId + '/storage/' + storageType + '/' + poolKey;
|
|
26
26
|
try {
|
|
27
27
|
const parser = (raw) => {
|
|
28
|
-
return raw.
|
|
28
|
+
return raw.deleted;
|
|
29
29
|
};
|
|
30
30
|
const result = await this.requestObject(cmd, null, parser, 'DELETE');
|
|
31
31
|
const re = result.getData();
|
|
@@ -33,7 +33,7 @@ class StorageEndpoint extends Endpoint_1.Endpoint {
|
|
|
33
33
|
console.log('clearpool wrong data', { result, parsed: re });
|
|
34
34
|
throw new Error('Something went wrong');
|
|
35
35
|
}
|
|
36
|
-
return re.
|
|
36
|
+
return re.deleted;
|
|
37
37
|
}
|
|
38
38
|
catch (ex) {
|
|
39
39
|
if (this.httpClient.isDebugEnabled()) {
|
|
@@ -90,7 +90,7 @@ class WorkspaceMemberEndpoint extends Endpoint_1.Endpoint {
|
|
|
90
90
|
userAction.userId = rawUserEvent.user;
|
|
91
91
|
userAction.workspaceId = rawUserEvent.workspace;
|
|
92
92
|
userAction.action = rawUserEvent.action;
|
|
93
|
-
userAction.resourceId = rawUserEvent.
|
|
93
|
+
userAction.resourceId = rawUserEvent.resource;
|
|
94
94
|
userAction.resourceType = rawUserEvent.resource_type;
|
|
95
95
|
userAction.description = rawUserEvent.description;
|
|
96
96
|
userAction.ip = rawUserEvent.ip;
|