attlaz-client 1.8.13 → 1.8.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/dist/Http/HttpClient.js +1 -2
- package/dist/Http/OAuthClient.js +4 -9
- package/dist/Model/Error/ClientError.js +0 -1
- package/dist/Model/Storage/StorageItem.d.ts +2 -0
- package/dist/Model/Storage/StorageItem.js +8 -0
- package/dist/Model/Storage/StorageItemInformation.d.ts +1 -0
- package/dist/Model/Storage/StorageItemInformation.js +7 -0
- package/dist/Model/Worker/WorkerConfig.d.ts +3 -0
- package/dist/Model/Worker/WorkerConfig.js +3 -0
- package/dist/Service/ProjectDeployEndpoint.js +0 -1
- package/dist/Service/StorageEndpoint.d.ts +2 -2
- package/dist/Service/StorageEndpoint.js +11 -3
- package/dist/Service/TaskExecutionRequestEndpoint.js +1 -1
- package/dist/Service/WorkerConfigEndpoint.js +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +7 -7
package/dist/Http/HttpClient.js
CHANGED
|
@@ -43,8 +43,7 @@ class HttpClient {
|
|
|
43
43
|
jsonData = JSON.parse(rawData);
|
|
44
44
|
}
|
|
45
45
|
catch (e) {
|
|
46
|
-
console.
|
|
47
|
-
console.error('Unable to parse response data to JSON');
|
|
46
|
+
console.error('Unable to parse response data to JSON', { statusText: httpResponse.statusText, error: e });
|
|
48
47
|
}
|
|
49
48
|
httpResponse.body = jsonData;
|
|
50
49
|
}
|
package/dist/Http/OAuthClient.js
CHANGED
|
@@ -30,7 +30,6 @@ class OAuthClient {
|
|
|
30
30
|
}
|
|
31
31
|
async authenticate(username = null, password = null) {
|
|
32
32
|
//TODO: should we encrypt the password in the client (or is https save enough)?
|
|
33
|
-
console.log('Authenticate');
|
|
34
33
|
try {
|
|
35
34
|
let accessToken;
|
|
36
35
|
if (username !== null && username !== undefined && password !== null && password !== undefined) {
|
|
@@ -53,7 +52,9 @@ class OAuthClient {
|
|
|
53
52
|
}
|
|
54
53
|
}
|
|
55
54
|
async refreshToken() {
|
|
56
|
-
|
|
55
|
+
if (this.debug) {
|
|
56
|
+
console.debug('[OAuthClient] refresh token');
|
|
57
|
+
}
|
|
57
58
|
if (this.oauthToken === null) {
|
|
58
59
|
throw new Error('unable to refresh token, auth token not set');
|
|
59
60
|
}
|
|
@@ -63,7 +64,6 @@ class OAuthClient {
|
|
|
63
64
|
this.oathClientToken = this.tokenToOauthClientToken(this.oauthToken);
|
|
64
65
|
}
|
|
65
66
|
catch (e) {
|
|
66
|
-
console.log('Error during refresh token', e);
|
|
67
67
|
throw ClientError_1.ClientError.fromError(e);
|
|
68
68
|
}
|
|
69
69
|
}
|
|
@@ -90,21 +90,16 @@ class OAuthClient {
|
|
|
90
90
|
if (this.refreshTokenPromise === null) {
|
|
91
91
|
this.refreshTokenPromise = this.refreshToken();
|
|
92
92
|
await this.refreshTokenPromise;
|
|
93
|
-
// this.refreshTokenPromise.then(() => {
|
|
94
93
|
this.refreshTokenPromise = null;
|
|
95
|
-
console.log('Refresh token done');
|
|
96
|
-
// });
|
|
97
94
|
}
|
|
98
95
|
else {
|
|
99
|
-
console.log('Waiting for refresh token promise');
|
|
100
96
|
await this.refreshTokenPromise;
|
|
101
|
-
console.log('Refresh token promise resolved');
|
|
102
97
|
}
|
|
103
98
|
}
|
|
104
99
|
}
|
|
105
100
|
const requestData = this.createRequestData(action, parameters, method, signWithOauthToken);
|
|
106
101
|
if (this.debug) {
|
|
107
|
-
console.debug('[
|
|
102
|
+
console.debug('[OAuthClient] Request: ' + requestData.method.toUpperCase() + ' ' + requestData.getFullUrl());
|
|
108
103
|
}
|
|
109
104
|
try {
|
|
110
105
|
const response = await HttpClient_1.HttpClient.request2(requestData);
|
|
@@ -9,7 +9,6 @@ class ClientError {
|
|
|
9
9
|
this.code = code;
|
|
10
10
|
}
|
|
11
11
|
static fromError(error) {
|
|
12
|
-
console.log('Incoming error', error);
|
|
13
12
|
if (error.body !== undefined && error.body !== null && error.body.error !== undefined && error.body.error !== null) {
|
|
14
13
|
error = error.body.error;
|
|
15
14
|
}
|
|
@@ -2,5 +2,13 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.StorageItem = void 0;
|
|
4
4
|
class StorageItem {
|
|
5
|
+
static parse(raw) {
|
|
6
|
+
let storageItem = new StorageItem();
|
|
7
|
+
storageItem.key = raw.key;
|
|
8
|
+
storageItem.bytes = raw.bytes;
|
|
9
|
+
storageItem.value = raw.value;
|
|
10
|
+
storageItem.expiration = raw.expiration === null ? null : new Date(raw.expiration);
|
|
11
|
+
return storageItem;
|
|
12
|
+
}
|
|
5
13
|
}
|
|
6
14
|
exports.StorageItem = StorageItem;
|
|
@@ -2,5 +2,12 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.StorageItemInformation = void 0;
|
|
4
4
|
class StorageItemInformation {
|
|
5
|
+
static parse(raw) {
|
|
6
|
+
let storageItemInformation = new StorageItemInformation();
|
|
7
|
+
storageItemInformation.key = raw.key;
|
|
8
|
+
storageItemInformation.bytes = raw.bytes;
|
|
9
|
+
storageItemInformation.expiration = raw.expiration === null ? null : new Date(raw.expiration);
|
|
10
|
+
return storageItemInformation;
|
|
11
|
+
}
|
|
5
12
|
}
|
|
6
13
|
exports.StorageItemInformation = StorageItemInformation;
|
|
@@ -6,6 +6,9 @@ export declare class WorkerConfig {
|
|
|
6
6
|
static KEY_CPU_LIMIT: string;
|
|
7
7
|
static KEY_PLATFORM: string;
|
|
8
8
|
static KEY_WORKER_VERSION: string;
|
|
9
|
+
static KEY_API_ENDPOINT: string;
|
|
10
|
+
static KEY_API_CLIENT_ID: string;
|
|
11
|
+
static KEY_API_CLIENT_SECRET: string;
|
|
9
12
|
projectEnvironment: string;
|
|
10
13
|
key: string;
|
|
11
14
|
value: DataValueValue | null;
|
|
@@ -18,3 +18,6 @@ WorkerConfig.KEY_MEMORY_LIMIT = 'memory_limit';
|
|
|
18
18
|
WorkerConfig.KEY_CPU_LIMIT = 'cpu_limit';
|
|
19
19
|
WorkerConfig.KEY_PLATFORM = 'platform';
|
|
20
20
|
WorkerConfig.KEY_WORKER_VERSION = 'worker_version';
|
|
21
|
+
WorkerConfig.KEY_API_ENDPOINT = 'api_endpoint';
|
|
22
|
+
WorkerConfig.KEY_API_CLIENT_ID = 'api_client_id';
|
|
23
|
+
WorkerConfig.KEY_API_CLIENT_SECRET = 'api_client_secret';
|
|
@@ -40,7 +40,6 @@ class ProjectDeployEndpoint extends Endpoint_1.Endpoint {
|
|
|
40
40
|
try {
|
|
41
41
|
const projectDeploy = await this.httpClient.request('/projectenvironments/' + projectEnvironmentId + '/deploys', {}, 'POST');
|
|
42
42
|
// TODO: parse deploy
|
|
43
|
-
console.log('Parse deploy', projectDeploy);
|
|
44
43
|
return projectDeploy;
|
|
45
44
|
}
|
|
46
45
|
catch (error) {
|
|
@@ -8,7 +8,7 @@ export declare class StorageEndpoint extends Endpoint {
|
|
|
8
8
|
getInformation(projectEnvironmentId: string, storageType: StorageType): Promise<DataResult<StorageInformation>>;
|
|
9
9
|
clearPool(projectEnvironmentId: string, storageType: StorageType, poolKey: string): Promise<DataResult<any>>;
|
|
10
10
|
getPoolItemsInformation(projectEnvironmentId: string, storageType: StorageType, poolKey: string): Promise<DataResult<StorageItemInformation[]>>;
|
|
11
|
-
getItem(projectEnvironmentId: string, storageType: StorageType, poolKey: string, storageItemKey: string): Promise<
|
|
12
|
-
setItem(projectEnvironmentId: string, storageType: StorageType, poolKey: string, storageItem: StorageItem): Promise<
|
|
11
|
+
getItem(projectEnvironmentId: string, storageType: StorageType, poolKey: string, storageItemKey: string): Promise<StorageItem | null>;
|
|
12
|
+
setItem(projectEnvironmentId: string, storageType: StorageType, poolKey: string, storageItem: StorageItem): Promise<void>;
|
|
13
13
|
deleteItem(projectEnvironmentId: string, storageType: StorageType, poolKey: string, storageItemKey: string): Promise<DataResult<StorageItem>>;
|
|
14
14
|
}
|
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.StorageEndpoint = void 0;
|
|
4
4
|
const Endpoint_1 = require("./Endpoint");
|
|
5
|
+
const StorageItem_1 = require("../Model/Storage/StorageItem");
|
|
6
|
+
const StorageItemInformation_1 = require("../Model/Storage/StorageItemInformation");
|
|
5
7
|
class StorageEndpoint extends Endpoint_1.Endpoint {
|
|
6
8
|
async getInformation(projectEnvironmentId, storageType) {
|
|
7
9
|
let cmd = '/projectenvironments/' + projectEnvironmentId + '/storage/' + storageType;
|
|
@@ -33,6 +35,7 @@ class StorageEndpoint extends Endpoint_1.Endpoint {
|
|
|
33
35
|
let cmd = '/projectenvironments/' + projectEnvironmentId + '/storage/' + storageType + '/' + poolKey + '/items';
|
|
34
36
|
try {
|
|
35
37
|
const result = await this.request(cmd, null, 'GET');
|
|
38
|
+
result.setData(this.parseCollection(result, StorageItemInformation_1.StorageItemInformation.parse));
|
|
36
39
|
return result;
|
|
37
40
|
}
|
|
38
41
|
catch (ex) {
|
|
@@ -46,11 +49,16 @@ class StorageEndpoint extends Endpoint_1.Endpoint {
|
|
|
46
49
|
let cmd = '/projectenvironments/' + projectEnvironmentId + '/storage/' + storageType + '/' + poolKey + '/items/' + storageItemKey;
|
|
47
50
|
try {
|
|
48
51
|
const result = await this.request(cmd, null, 'GET');
|
|
49
|
-
|
|
52
|
+
if (result.getData() === null) {
|
|
53
|
+
return null;
|
|
54
|
+
}
|
|
55
|
+
else {
|
|
56
|
+
return StorageItem_1.StorageItem.parse(result.getData());
|
|
57
|
+
}
|
|
50
58
|
}
|
|
51
59
|
catch (ex) {
|
|
52
60
|
if (this.httpClient.isDebugEnabled()) {
|
|
53
|
-
console.error('Failed to get storage
|
|
61
|
+
console.error('Failed to get storage item', ex);
|
|
54
62
|
}
|
|
55
63
|
throw ex;
|
|
56
64
|
}
|
|
@@ -59,7 +67,7 @@ class StorageEndpoint extends Endpoint_1.Endpoint {
|
|
|
59
67
|
let cmd = '/projectenvironments/' + projectEnvironmentId + '/storage/' + storageType + '/' + poolKey + '/items/' + storageItem.key;
|
|
60
68
|
try {
|
|
61
69
|
const result = await this.request(cmd, { 'storage_item': storageItem }, 'POST');
|
|
62
|
-
return
|
|
70
|
+
return;
|
|
63
71
|
}
|
|
64
72
|
catch (ex) {
|
|
65
73
|
if (this.httpClient.isDebugEnabled()) {
|
|
@@ -11,7 +11,7 @@ class TaskExecutionRequestEndpoint extends Endpoint_1.Endpoint {
|
|
|
11
11
|
try {
|
|
12
12
|
// TODO: parse
|
|
13
13
|
const result = await this.httpClient.request(url, params, 'POST');
|
|
14
|
-
console.log('TODO: parse postTaskExecutionRequest result', result);
|
|
14
|
+
// console.log('TODO: parse postTaskExecutionRequest result', result);
|
|
15
15
|
return result;
|
|
16
16
|
}
|
|
17
17
|
catch (ex) {
|
|
@@ -33,7 +33,7 @@ class WorkerConfigEndpoint extends Endpoint_1.Endpoint {
|
|
|
33
33
|
try {
|
|
34
34
|
let url = '/projectenvironments/' + workerConfig.projectEnvironment + '/workerconfiguration';
|
|
35
35
|
const result = await this.request(url, workerConfig, 'POST');
|
|
36
|
-
console.log(result);
|
|
36
|
+
// console.log(result);
|
|
37
37
|
return WorkerConfig_1.WorkerConfig.parse(result);
|
|
38
38
|
}
|
|
39
39
|
catch (error) {
|
package/dist/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const VERSION = "1.8.
|
|
1
|
+
export declare const VERSION = "1.8.16";
|
package/dist/version.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "attlaz-client",
|
|
3
|
-
"version": "1.8.
|
|
3
|
+
"version": "1.8.16",
|
|
4
4
|
"description": "Javascript Client to access Attlaz API",
|
|
5
5
|
"types": "./dist/index.d.ts",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -30,16 +30,16 @@
|
|
|
30
30
|
"popsicle": "^12.1.0"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
|
-
"@types/jest": "^
|
|
34
|
-
"@types/node": "^
|
|
35
|
-
"jest": "^
|
|
33
|
+
"@types/jest": "^28.1.6",
|
|
34
|
+
"@types/node": "^18.7.2",
|
|
35
|
+
"jest": "^28.1.3",
|
|
36
36
|
"rimraf": "^3.0.2",
|
|
37
37
|
"rollup-plugin-commonjs": "^10.1.0",
|
|
38
38
|
"rollup-plugin-node-resolve": "^5.2.0",
|
|
39
39
|
"rollup-plugin-typescript": "^1.0.1",
|
|
40
|
-
"ts-jest": "^
|
|
41
|
-
"typescript": "^4.
|
|
42
|
-
"dotenv": "^16.0.
|
|
40
|
+
"ts-jest": "^28.0.7",
|
|
41
|
+
"typescript": "^4.7.4",
|
|
42
|
+
"dotenv": "^16.0.1"
|
|
43
43
|
},
|
|
44
44
|
"directories": {
|
|
45
45
|
"test": "test"
|