attlaz-client 1.4.3 → 1.4.4
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/Client.d.ts +24 -1
- package/dist/Client.js +51 -31
- package/dist/Http/HttpClient.js +14 -17
- package/dist/Http/HttpClientRequest.js +3 -7
- package/dist/Http/HttpClientRequest.spec.js +3 -5
- package/dist/Http/HttpClientResponse.js +1 -5
- package/dist/Http/OAuthClient.js +15 -17
- package/dist/Http/OAuthClient.spec.js +4 -6
- package/dist/Http/OAuthClientOptions.js +1 -5
- package/dist/Http/OAuthClientToken.js +1 -5
- package/dist/Model/Adapter/Adapter.js +1 -5
- package/dist/Model/Adapter/AdapterConfiguration.js +1 -5
- package/dist/Model/Adapter/AdapterConnection.js +1 -5
- package/dist/Model/Config.js +7 -11
- package/dist/Model/Error/ClientError.js +12 -16
- package/dist/Model/Event/EventType.js +2 -5
- package/dist/Model/HealthAlert/HealthAlert.js +4 -8
- package/dist/Model/HealthAlert/HealthAlertStatus.js +6 -9
- package/dist/Model/HealthAlert/HealthTestType.js +6 -9
- package/dist/Model/Log/Log.js +5 -9
- package/dist/Model/Log/LogLevel.js +6 -9
- package/dist/Model/Log/LogQuery.js +1 -5
- package/dist/Model/Log/LogStreamId.js +1 -5
- package/dist/Model/Log/LogType.js +7 -10
- package/dist/Model/Messaging/Channel/Channel.js +8 -12
- package/dist/Model/Messaging/Channel/ChannelData.js +1 -5
- package/dist/Model/Messaging/Channel/ChannelType.js +6 -9
- package/dist/Model/Messaging/Channel/EmailChannelData.js +4 -8
- package/dist/Model/Messaging/Channel/PushChannelData.js +4 -8
- package/dist/Model/Messaging/Channel/SlackChannelData.js +4 -8
- package/dist/Model/Messaging/Channel/SmsChannelData.js +4 -8
- package/dist/Model/Messaging/Channel/WebhookChannelData.js +4 -8
- package/dist/Model/Messaging/ChannelHistory.js +3 -7
- package/dist/Model/Messaging/Subscriber.js +4 -8
- package/dist/Model/Notification.js +1 -5
- package/dist/Model/PagedResult.js +4 -8
- package/dist/Model/Project/Language.js +4 -8
- package/dist/Model/Project/Project.js +4 -8
- package/dist/Model/Project/ProjectDeploy.js +8 -12
- package/dist/Model/Project/ProjectDeployCommit.js +1 -5
- package/dist/Model/Project/ProjectDeployStatus.js +6 -9
- package/dist/Model/Project/ProjectEnvironment.js +6 -10
- package/dist/Model/Queue/QueueStatus.js +1 -5
- package/dist/Model/Result/DataResult.js +1 -5
- package/dist/Model/Result/DataResultCollection.js +1 -5
- package/dist/Model/Result/ResultError.js +1 -5
- package/dist/Model/SourcesAccount.js +1 -5
- package/dist/Model/SourcesAccountRepository.js +1 -5
- package/dist/Model/State.js +6 -9
- package/dist/Model/StateAware.js +0 -2
- package/dist/Model/Storage/Storage.js +1 -5
- package/dist/Model/Storage/StorageType.js +6 -9
- package/dist/Model/Task.js +4 -8
- package/dist/Model/TaskExecution.js +1 -5
- package/dist/Model/TaskExecutionHistory.js +3 -7
- package/dist/Model/TaskExecutionResponse.js +1 -5
- package/dist/Model/TaskExecutionStatus.js +6 -9
- package/dist/Model/TaskExecutionSummary.js +7 -11
- package/dist/Model/TaskSummary.js +8 -12
- package/dist/Model/Team/Team.js +1 -5
- package/dist/Model/Team/TeamMember.js +1 -5
- package/dist/Model/Team/TeamMemberInvite.js +3 -7
- package/dist/Model/Team/TeamMemberInvite2.js +1 -5
- package/dist/Model/Team/TeamMemberInviteState.js +6 -9
- package/dist/Model/Team/TeamMemberRole.js +5 -8
- package/dist/Model/Trigger/ApiTrigger.js +4 -8
- package/dist/Model/Trigger/ApiTriggerData.js +2 -6
- package/dist/Model/Trigger/ScheduleTrigger.js +4 -8
- package/dist/Model/Trigger/ScheduleTriggerData.js +2 -6
- package/dist/Model/Trigger/Trigger.js +15 -19
- package/dist/Model/Trigger/TriggerData.js +1 -5
- package/dist/Model/Trigger/TriggerType.js +6 -9
- package/dist/Model/Trigger/WebhookTrigger.js +4 -8
- package/dist/Model/Trigger/WebhookTriggerData.js +2 -6
- package/dist/Model/User/UserAuthProvider.js +6 -10
- package/dist/Model/User.js +6 -10
- package/dist/Model/Worker/Worker.js +7 -11
- package/dist/Model/Worker/WorkerConfig.js +1 -5
- package/dist/Model/Worker/WorkerImage.js +4 -8
- package/dist/Model/Worker/WorkerInstance.js +3 -7
- package/dist/Model/Worker/WorkerInstanceState.js +6 -9
- package/dist/Model/Worker/WorkerState.js +6 -9
- package/dist/Service/AdapterEndpoint.js +10 -14
- package/dist/Service/ChannelEndpoint.d.ts +3 -1
- package/dist/Service/ChannelEndpoint.js +11 -13
- package/dist/Service/ConfigEndpoint.js +8 -12
- package/dist/Service/Endpoint.js +3 -7
- package/dist/Service/HealthAlertEndpoint.d.ts +2 -1
- package/dist/Service/HealthAlertEndpoint.js +6 -8
- package/dist/Service/LanguageEndpoint.js +6 -10
- package/dist/Service/LogEndpoint.js +15 -19
- package/dist/Service/NotificationsEndpoint.d.ts +2 -1
- package/dist/Service/NotificationsEndpoint.js +4 -7
- package/dist/Service/ProjectDeployEndpoint.d.ts +2 -1
- package/dist/Service/ProjectDeployEndpoint.js +7 -9
- package/dist/Service/ProjectEndpoint.d.ts +2 -1
- package/dist/Service/ProjectEndpoint.js +9 -11
- package/dist/Service/ProjectEnvironmentEndpoint.d.ts +2 -1
- package/dist/Service/ProjectEnvironmentEndpoint.js +2 -6
- package/dist/Service/QueueEndpoint.d.ts +2 -1
- package/dist/Service/QueueEndpoint.js +6 -10
- package/dist/Service/SourcesAccountEndpoint.d.ts +3 -1
- package/dist/Service/SourcesAccountEndpoint.js +6 -8
- package/dist/Service/StorageEndpoint.d.ts +4 -1
- package/dist/Service/StorageEndpoint.js +9 -11
- package/dist/Service/SubscriberEndpoint.d.ts +2 -1
- package/dist/Service/SubscriberEndpoint.js +7 -9
- package/dist/Service/TaskEndpoint.d.ts +3 -1
- package/dist/Service/TaskEndpoint.js +14 -15
- package/dist/Service/TaskExecutionEndpoint.d.ts +5 -1
- package/dist/Service/TaskExecutionEndpoint.js +20 -20
- package/dist/Service/TaskExecutionRequestEndpoint.d.ts +2 -1
- package/dist/Service/TaskExecutionRequestEndpoint.js +2 -6
- package/dist/Service/TeamMemberEndpoint.d.ts +3 -1
- package/dist/Service/TeamMemberEndpoint.js +15 -15
- package/dist/Service/TeamsEndpoint.d.ts +2 -1
- package/dist/Service/TeamsEndpoint.js +6 -8
- package/dist/Service/TriggerEndpoint.d.ts +2 -1
- package/dist/Service/TriggerEndpoint.js +9 -11
- package/dist/Service/UserEndpoint.d.ts +3 -1
- package/dist/Service/UserEndpoint.js +11 -13
- package/dist/Service/WorkerConfigEndpoint.d.ts +2 -1
- package/dist/Service/WorkerConfigEndpoint.js +7 -9
- package/dist/Service/WorkerEndpoint.d.ts +3 -1
- package/dist/Service/WorkerEndpoint.js +9 -11
- package/dist/Utils.js +2 -9
- package/dist/Utils.spec.js +23 -20
- package/dist/auth.spec.js +22 -24
- package/dist/data.spec.js +3 -5
- package/dist/index.js +100 -202
- package/dist/test.js +11 -13
- package/package.json +1 -2
package/dist/Client.d.ts
CHANGED
|
@@ -1,5 +1,28 @@
|
|
|
1
|
-
import { AdapterEndpoint, ChannelEndpoint, ConfigEndpoint, HealthAlertEndpoint, LanguageEndpoint, LogEndpoint, NotificationsEndpoint, OAuthClient, ProjectDeployEndpoint, ProjectEndpoint, ProjectEnvironmentEndpoint, QueueEndpoint, SourcesAccountEndpoint, StorageEndpoint, SubscriberEndpoint, TaskEndpoint, TaskExecutionEndpoint, TaskExecutionRequestEndpoint, TeamMemberEndpoint, TeamsEndpoint, TriggerEndpoint, UserEndpoint, WorkerConfigEndpoint, WorkerEndpoint } from ".";
|
|
2
1
|
import { OAuthClientToken } from './Http/OAuthClientToken';
|
|
2
|
+
import { WorkerEndpoint } from './Service/WorkerEndpoint';
|
|
3
|
+
import { AdapterEndpoint } from './Service/AdapterEndpoint';
|
|
4
|
+
import { ProjectEnvironmentEndpoint } from './Service/ProjectEnvironmentEndpoint';
|
|
5
|
+
import { ProjectEndpoint } from './Service/ProjectEndpoint';
|
|
6
|
+
import { TaskExecutionRequestEndpoint } from './Service/TaskExecutionRequestEndpoint';
|
|
7
|
+
import { OAuthClient } from './Http/OAuthClient';
|
|
8
|
+
import { WorkerConfigEndpoint } from './Service/WorkerConfigEndpoint';
|
|
9
|
+
import { TeamsEndpoint } from './Service/TeamsEndpoint';
|
|
10
|
+
import { UserEndpoint } from './Service/UserEndpoint';
|
|
11
|
+
import { ConfigEndpoint } from './Service/ConfigEndpoint';
|
|
12
|
+
import { SubscriberEndpoint } from './Service/SubscriberEndpoint';
|
|
13
|
+
import { TaskEndpoint } from './Service/TaskEndpoint';
|
|
14
|
+
import { TeamMemberEndpoint } from './Service/TeamMemberEndpoint';
|
|
15
|
+
import { StorageEndpoint } from './Service/StorageEndpoint';
|
|
16
|
+
import { QueueEndpoint } from './Service/QueueEndpoint';
|
|
17
|
+
import { NotificationsEndpoint } from './Service/NotificationsEndpoint';
|
|
18
|
+
import { ProjectDeployEndpoint } from './Service/ProjectDeployEndpoint';
|
|
19
|
+
import { SourcesAccountEndpoint } from './Service/SourcesAccountEndpoint';
|
|
20
|
+
import { LanguageEndpoint } from './Service/LanguageEndpoint';
|
|
21
|
+
import { ChannelEndpoint } from './Service/ChannelEndpoint';
|
|
22
|
+
import { HealthAlertEndpoint } from './Service/HealthAlertEndpoint';
|
|
23
|
+
import { TaskExecutionEndpoint } from './Service/TaskExecutionEndpoint';
|
|
24
|
+
import { LogEndpoint } from './Service/LogEndpoint';
|
|
25
|
+
import { TriggerEndpoint } from './Service/TriggerEndpoint';
|
|
3
26
|
export declare class Client {
|
|
4
27
|
private apiEndpoint;
|
|
5
28
|
private clientId;
|
package/dist/Client.js
CHANGED
|
@@ -1,8 +1,29 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import { WorkerEndpoint } from './Service/WorkerEndpoint';
|
|
2
|
+
import { AdapterEndpoint } from './Service/AdapterEndpoint';
|
|
3
|
+
import { ProjectEnvironmentEndpoint } from './Service/ProjectEnvironmentEndpoint';
|
|
4
|
+
import { ProjectEndpoint } from './Service/ProjectEndpoint';
|
|
5
|
+
import { TaskExecutionRequestEndpoint } from './Service/TaskExecutionRequestEndpoint';
|
|
6
|
+
import { OAuthClient } from './Http/OAuthClient';
|
|
7
|
+
import { WorkerConfigEndpoint } from './Service/WorkerConfigEndpoint';
|
|
8
|
+
import { TeamsEndpoint } from './Service/TeamsEndpoint';
|
|
9
|
+
import { UserEndpoint } from './Service/UserEndpoint';
|
|
10
|
+
import { ConfigEndpoint } from './Service/ConfigEndpoint';
|
|
11
|
+
import { SubscriberEndpoint } from './Service/SubscriberEndpoint';
|
|
12
|
+
import { TaskEndpoint } from './Service/TaskEndpoint';
|
|
13
|
+
import { TeamMemberEndpoint } from './Service/TeamMemberEndpoint';
|
|
14
|
+
import { StorageEndpoint } from './Service/StorageEndpoint';
|
|
15
|
+
import { QueueEndpoint } from './Service/QueueEndpoint';
|
|
16
|
+
import { NotificationsEndpoint } from './Service/NotificationsEndpoint';
|
|
17
|
+
import { ProjectDeployEndpoint } from './Service/ProjectDeployEndpoint';
|
|
18
|
+
import { SourcesAccountEndpoint } from './Service/SourcesAccountEndpoint';
|
|
19
|
+
import { OAuthClientOptions } from './Http/OAuthClientOptions';
|
|
20
|
+
import { LanguageEndpoint } from './Service/LanguageEndpoint';
|
|
21
|
+
import { ChannelEndpoint } from './Service/ChannelEndpoint';
|
|
22
|
+
import { HealthAlertEndpoint } from './Service/HealthAlertEndpoint';
|
|
23
|
+
import { TaskExecutionEndpoint } from './Service/TaskExecutionEndpoint';
|
|
24
|
+
import { LogEndpoint } from './Service/LogEndpoint';
|
|
25
|
+
import { TriggerEndpoint } from './Service/TriggerEndpoint';
|
|
26
|
+
export class Client {
|
|
6
27
|
// private test: Map<string, any>;
|
|
7
28
|
// private socketService;
|
|
8
29
|
constructor(apiEndpoint, clientId, clientSecret) {
|
|
@@ -10,32 +31,32 @@ class Client {
|
|
|
10
31
|
this.clientId = clientId;
|
|
11
32
|
this.clientSecret = clientSecret;
|
|
12
33
|
this.Store = {
|
|
13
|
-
WorkerEndpoint
|
|
14
|
-
AdapterEndpoint
|
|
15
|
-
ProjectEndpoint
|
|
16
|
-
ProjectEnvironmentEndpoint
|
|
17
|
-
ProjectDeployEndpoint
|
|
18
|
-
QueueEndpoint
|
|
19
|
-
ChannelEndpoint
|
|
20
|
-
ConfigEndpoint
|
|
21
|
-
NotificationsEndpoint
|
|
22
|
-
SubscriberEndpoint
|
|
23
|
-
LogEndpoint
|
|
24
|
-
TaskEndpoint
|
|
25
|
-
TaskExecutionEndpoint
|
|
26
|
-
TaskExecutionRequestEndpoint
|
|
27
|
-
TeamsEndpoint
|
|
28
|
-
TriggerEndpoint
|
|
29
|
-
UserEndpoint
|
|
30
|
-
MemberEndpoint:
|
|
31
|
-
SourcesAccountEndpoint
|
|
32
|
-
LanguageEndpoint
|
|
33
|
-
StorageEndpoint
|
|
34
|
-
WorkerConfigEndpoint
|
|
35
|
-
HealthAlertEndpoint
|
|
34
|
+
WorkerEndpoint,
|
|
35
|
+
AdapterEndpoint,
|
|
36
|
+
ProjectEndpoint,
|
|
37
|
+
ProjectEnvironmentEndpoint,
|
|
38
|
+
ProjectDeployEndpoint,
|
|
39
|
+
QueueEndpoint,
|
|
40
|
+
ChannelEndpoint,
|
|
41
|
+
ConfigEndpoint,
|
|
42
|
+
NotificationsEndpoint,
|
|
43
|
+
SubscriberEndpoint,
|
|
44
|
+
LogEndpoint,
|
|
45
|
+
TaskEndpoint,
|
|
46
|
+
TaskExecutionEndpoint,
|
|
47
|
+
TaskExecutionRequestEndpoint,
|
|
48
|
+
TeamsEndpoint,
|
|
49
|
+
TriggerEndpoint,
|
|
50
|
+
UserEndpoint,
|
|
51
|
+
MemberEndpoint: TeamMemberEndpoint,
|
|
52
|
+
SourcesAccountEndpoint,
|
|
53
|
+
LanguageEndpoint,
|
|
54
|
+
StorageEndpoint,
|
|
55
|
+
WorkerConfigEndpoint,
|
|
56
|
+
HealthAlertEndpoint
|
|
36
57
|
};
|
|
37
|
-
const options = new
|
|
38
|
-
this.httpClient = new
|
|
58
|
+
const options = new OAuthClientOptions(apiEndpoint, clientId, clientSecret);
|
|
59
|
+
this.httpClient = new OAuthClient(options);
|
|
39
60
|
this.endpoints = new Map();
|
|
40
61
|
// this.test = new Map<string, any>();
|
|
41
62
|
//
|
|
@@ -159,4 +180,3 @@ class Client {
|
|
|
159
180
|
return this.endpoints.get(key);
|
|
160
181
|
}
|
|
161
182
|
}
|
|
162
|
-
exports.Client = Client;
|
package/dist/Http/HttpClient.js
CHANGED
|
@@ -1,14 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const __1 = require("..");
|
|
7
|
-
const HttpClientResponse_1 = require("./HttpClientResponse");
|
|
1
|
+
import { fetch } from 'popsicle';
|
|
2
|
+
import { Utils } from '../Utils';
|
|
3
|
+
// import {ClientError} from '..';
|
|
4
|
+
import { HttpClientResponse } from './HttpClientResponse';
|
|
5
|
+
import { ClientError } from '../Model/Error/ClientError';
|
|
8
6
|
// import {NegotiateHttpVersion} from 'popsicle-transport-http';
|
|
9
|
-
class HttpClient {
|
|
7
|
+
export class HttpClient {
|
|
10
8
|
static async get(url, requestData = {}) {
|
|
11
|
-
if (
|
|
9
|
+
if (Utils.isNullOrUndefined(requestData)) {
|
|
12
10
|
requestData = {};
|
|
13
11
|
}
|
|
14
12
|
// TODO: how to pass this?
|
|
@@ -16,10 +14,10 @@ class HttpClient {
|
|
|
16
14
|
// negotiateHttpVersion: NegotiateHttpVersion.HTTP1_ONLY
|
|
17
15
|
// }
|
|
18
16
|
// const controller = new AbortController();
|
|
19
|
-
const response = await
|
|
17
|
+
const response = await fetch(url, requestData);
|
|
20
18
|
//TODO: validate status
|
|
21
|
-
const error =
|
|
22
|
-
if (!
|
|
19
|
+
const error = ClientError.byStatus(response.status, response.statusText);
|
|
20
|
+
if (!Utils.isNullOrUndefined(error)) {
|
|
23
21
|
// const body: string = await response.text();
|
|
24
22
|
// console.log('Text' + body);
|
|
25
23
|
//
|
|
@@ -49,8 +47,8 @@ class HttpClient {
|
|
|
49
47
|
};
|
|
50
48
|
// TODO: set user agent
|
|
51
49
|
// rawRequest.negotiateHttpVersion = NegotiateHttpVersion.HTTP1_ONLY;
|
|
52
|
-
const response = await
|
|
53
|
-
const httpResponse = new
|
|
50
|
+
const response = await fetch(request.getFullUrl(), rawRequest);
|
|
51
|
+
const httpResponse = new HttpClientResponse();
|
|
54
52
|
httpResponse.status = response.status;
|
|
55
53
|
httpResponse.statusText = response.statusText;
|
|
56
54
|
// TODO: should we get JSON immediately?
|
|
@@ -66,8 +64,8 @@ class HttpClient {
|
|
|
66
64
|
console.error('Unable to parse response data to JSON');
|
|
67
65
|
}
|
|
68
66
|
httpResponse.body = jsonData;
|
|
69
|
-
const error =
|
|
70
|
-
if (!
|
|
67
|
+
const error = ClientError.byStatus(response.status, response.statusText);
|
|
68
|
+
if (!Utils.isNullOrUndefined(error)) {
|
|
71
69
|
// const body: string = await response.text();
|
|
72
70
|
// console.log('Text' + body);
|
|
73
71
|
//
|
|
@@ -91,7 +89,6 @@ class HttpClient {
|
|
|
91
89
|
return httpResponse;
|
|
92
90
|
}
|
|
93
91
|
}
|
|
94
|
-
exports.HttpClient = HttpClient;
|
|
95
92
|
HttpClient.HTTP_ERROR = 'xxx';
|
|
96
93
|
HttpClient.HTTP_BAD_REQUEST = '400';
|
|
97
94
|
HttpClient.HTTP_UNAUTHORIZED = '401';
|
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.HttpClientRequest = void 0;
|
|
4
|
-
const Utils_1 = require("../Utils");
|
|
5
|
-
class HttpClientRequest {
|
|
1
|
+
import { Utils } from '../Utils';
|
|
2
|
+
export class HttpClientRequest {
|
|
6
3
|
constructor(url, method = HttpClientRequest.GET) {
|
|
7
4
|
this.headers = {};
|
|
8
5
|
this.body = null;
|
|
@@ -13,7 +10,7 @@ class HttpClientRequest {
|
|
|
13
10
|
this.setHeader('Content-Type', 'application/json');
|
|
14
11
|
}
|
|
15
12
|
setBasicAuth(user, password) {
|
|
16
|
-
this.setHeader('Authorization', 'Basic ' +
|
|
13
|
+
this.setHeader('Authorization', 'Basic ' + Utils.base64encode(user + ':' + password));
|
|
17
14
|
}
|
|
18
15
|
setHeader(key, value) {
|
|
19
16
|
this.headers[key] = value;
|
|
@@ -34,7 +31,6 @@ class HttpClientRequest {
|
|
|
34
31
|
return result;
|
|
35
32
|
}
|
|
36
33
|
}
|
|
37
|
-
exports.HttpClientRequest = HttpClientRequest;
|
|
38
34
|
HttpClientRequest.GET = 'GET';
|
|
39
35
|
HttpClientRequest.POST = 'POST';
|
|
40
36
|
HttpClientRequest.PUT = 'PUT';
|
|
@@ -1,14 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const HttpClientRequest_1 = require("./HttpClientRequest");
|
|
1
|
+
import { HttpClientRequest } from './HttpClientRequest';
|
|
4
2
|
test('Test query string', async () => {
|
|
5
|
-
const request = new
|
|
3
|
+
const request = new HttpClientRequest('http://example.com');
|
|
6
4
|
expect(request.getFullUrl()).toBe('http://example.com');
|
|
7
5
|
request.addQueryParam('queryparam1', 'queryparam1value');
|
|
8
6
|
expect(request.getFullUrl()).toBe('http://example.com?queryparam1=queryparam1value');
|
|
9
7
|
});
|
|
10
8
|
test('Test query string - add to existing query string', async () => {
|
|
11
|
-
const request = new
|
|
9
|
+
const request = new HttpClientRequest('http://example.com?queryparam0=queryparam0value');
|
|
12
10
|
expect(request.getFullUrl()).toBe('http://example.com?queryparam0=queryparam0value');
|
|
13
11
|
request.addQueryParam('queryparam1', 'queryparam1value');
|
|
14
12
|
expect(request.getFullUrl()).toBe('http://example.com?queryparam0=queryparam0value&queryparam1=queryparam1value');
|
package/dist/Http/OAuthClient.js
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
class OAuthClient {
|
|
1
|
+
import { ClientError } from '../Model/Error/ClientError';
|
|
2
|
+
import { HttpClient } from './HttpClient';
|
|
3
|
+
import { HttpClientRequest } from './HttpClientRequest';
|
|
4
|
+
import { Utils } from '../Utils';
|
|
5
|
+
import * as ClientOAuth2 from 'client-oauth2';
|
|
6
|
+
// import {Token} from 'client-oauth2';
|
|
7
|
+
// import ClientOAuth2 = require('client-oauth2');
|
|
8
|
+
export class OAuthClient {
|
|
10
9
|
constructor(options) {
|
|
11
10
|
this.debug = false;
|
|
12
11
|
this.oauthToken = null;
|
|
@@ -26,7 +25,7 @@ class OAuthClient {
|
|
|
26
25
|
//TODO: should we encrypt the password in the client (or is https save enough)?
|
|
27
26
|
try {
|
|
28
27
|
let accessToken;
|
|
29
|
-
if (!
|
|
28
|
+
if (!Utils.isNullOrUndefined(username) && !Utils.isNullOrUndefined(password)) {
|
|
30
29
|
// Password flow
|
|
31
30
|
accessToken = await this.oauthClient.owner.getToken(username, password);
|
|
32
31
|
}
|
|
@@ -39,7 +38,7 @@ class OAuthClient {
|
|
|
39
38
|
}
|
|
40
39
|
catch (e) {
|
|
41
40
|
console.log(e);
|
|
42
|
-
throw
|
|
41
|
+
throw ClientError.fromError(e);
|
|
43
42
|
}
|
|
44
43
|
}
|
|
45
44
|
async refreshToken() {
|
|
@@ -48,7 +47,7 @@ class OAuthClient {
|
|
|
48
47
|
this.oauthToken = await this.oauthToken.refresh();
|
|
49
48
|
}
|
|
50
49
|
catch (e) {
|
|
51
|
-
const error =
|
|
50
|
+
const error = ClientError.fromError(e);
|
|
52
51
|
throw error;
|
|
53
52
|
}
|
|
54
53
|
}
|
|
@@ -64,7 +63,7 @@ class OAuthClient {
|
|
|
64
63
|
}
|
|
65
64
|
async request(action, parameters = null, method = 'GET', signWithOauthToken = true) {
|
|
66
65
|
if (signWithOauthToken && !this.isAuthenticated()) {
|
|
67
|
-
throw new
|
|
66
|
+
throw new ClientError('Unable to perform request, access token not provided');
|
|
68
67
|
}
|
|
69
68
|
else {
|
|
70
69
|
if (signWithOauthToken && this.oauthToken.expired()) {
|
|
@@ -75,11 +74,11 @@ class OAuthClient {
|
|
|
75
74
|
console.info('[Client request] ', requestData);
|
|
76
75
|
}
|
|
77
76
|
try {
|
|
78
|
-
const response = await
|
|
77
|
+
const response = await HttpClient.request2(requestData);
|
|
79
78
|
return response.body;
|
|
80
79
|
}
|
|
81
80
|
catch (e) {
|
|
82
|
-
throw
|
|
81
|
+
throw ClientError.fromError(e);
|
|
83
82
|
}
|
|
84
83
|
}
|
|
85
84
|
}
|
|
@@ -136,7 +135,7 @@ class OAuthClient {
|
|
|
136
135
|
}
|
|
137
136
|
createRequestData(action, parameters = null, method = 'GET', signWithOauthToken = true) {
|
|
138
137
|
const url = this.getUri(action);
|
|
139
|
-
let requestData = new
|
|
138
|
+
let requestData = new HttpClientRequest(url, method);
|
|
140
139
|
if ((method === 'POST' || method === 'DELETE' || method === 'PUT') && parameters !== null && parameters !== undefined) {
|
|
141
140
|
if (typeof parameters === 'object') {
|
|
142
141
|
parameters = JSON.stringify(parameters);
|
|
@@ -181,4 +180,3 @@ class OAuthClient {
|
|
|
181
180
|
return requestObject;
|
|
182
181
|
}
|
|
183
182
|
}
|
|
184
|
-
exports.OAuthClient = OAuthClient;
|
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
const OAuthClient_1 = require("./OAuthClient");
|
|
4
|
-
const OAuthClientOptions_1 = require("./OAuthClientOptions");
|
|
1
|
+
import { OAuthClient } from './OAuthClient';
|
|
2
|
+
import { OAuthClientOptions } from './OAuthClientOptions';
|
|
5
3
|
test('Test enum parsing', async () => {
|
|
6
|
-
const options = new
|
|
7
|
-
const client = new
|
|
4
|
+
const options = new OAuthClientOptions('https://github.com/login', '3b938da6f58d6bef7d59', 'da05698a6bd449de9437e11ff0b99003f511e40f');
|
|
5
|
+
const client = new OAuthClient(options);
|
|
8
6
|
// client.getClient().cod.getToken()
|
|
9
7
|
// const x: any = await client.authenticate();
|
|
10
8
|
// console.log(x);
|
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.OAuthClientOptions = void 0;
|
|
4
|
-
class OAuthClientOptions {
|
|
1
|
+
export class OAuthClientOptions {
|
|
5
2
|
constructor(apiEndpoint, clientId, clientSecret) {
|
|
6
3
|
this.accessTokenUri = 'oauth/token';
|
|
7
4
|
this.authorizationUri = 'oauth/authorize';
|
|
@@ -13,4 +10,3 @@ class OAuthClientOptions {
|
|
|
13
10
|
this.clientSecret = clientSecret;
|
|
14
11
|
}
|
|
15
12
|
}
|
|
16
|
-
exports.OAuthClientOptions = OAuthClientOptions;
|
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.OAuthClientToken = void 0;
|
|
4
|
-
class OAuthClientToken {
|
|
1
|
+
export class OAuthClientToken {
|
|
5
2
|
static isExpired(token) {
|
|
6
3
|
console.log(token);
|
|
7
4
|
return token.expires <= new Date();
|
|
@@ -15,4 +12,3 @@ class OAuthClientToken {
|
|
|
15
12
|
return token;
|
|
16
13
|
}
|
|
17
14
|
}
|
|
18
|
-
exports.OAuthClientToken = OAuthClientToken;
|
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Adapter = void 0;
|
|
4
|
-
class Adapter {
|
|
1
|
+
export class Adapter {
|
|
5
2
|
static parse(rawAdapter) {
|
|
6
3
|
let adapter = new Adapter();
|
|
7
4
|
adapter.id = rawAdapter.id;
|
|
@@ -17,4 +14,3 @@ class Adapter {
|
|
|
17
14
|
return adapter;
|
|
18
15
|
}
|
|
19
16
|
}
|
|
20
|
-
exports.Adapter = Adapter;
|
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.AdapterConfiguration = void 0;
|
|
4
|
-
class AdapterConfiguration {
|
|
1
|
+
export class AdapterConfiguration {
|
|
5
2
|
static parse(rawAdapter) {
|
|
6
3
|
let configuration = new AdapterConfiguration();
|
|
7
4
|
configuration.id = rawAdapter.id;
|
|
@@ -13,4 +10,3 @@ class AdapterConfiguration {
|
|
|
13
10
|
return configuration;
|
|
14
11
|
}
|
|
15
12
|
}
|
|
16
|
-
exports.AdapterConfiguration = AdapterConfiguration;
|
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.AdapterConnection = void 0;
|
|
4
|
-
class AdapterConnection {
|
|
1
|
+
export class AdapterConnection {
|
|
5
2
|
static parse(rawAdapterConnection) {
|
|
6
3
|
let adapterConnection = new AdapterConnection();
|
|
7
4
|
adapterConnection.id = rawAdapterConnection.id;
|
|
@@ -19,4 +16,3 @@ class AdapterConnection {
|
|
|
19
16
|
// return adapter;
|
|
20
17
|
}
|
|
21
18
|
}
|
|
22
|
-
exports.AdapterConnection = AdapterConnection;
|
package/dist/Model/Config.js
CHANGED
|
@@ -1,13 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const State_1 = require("./State");
|
|
5
|
-
const Utils_1 = require("../Utils");
|
|
6
|
-
class Config {
|
|
1
|
+
import { State } from './State';
|
|
2
|
+
import { Utils } from '../Utils';
|
|
3
|
+
export class Config {
|
|
7
4
|
constructor() {
|
|
8
5
|
this.inheritable = true;
|
|
9
6
|
this.sensitive = true;
|
|
10
|
-
this.state =
|
|
7
|
+
this.state = State.Active;
|
|
11
8
|
}
|
|
12
9
|
static parse(rawConfig) {
|
|
13
10
|
let config = new Config();
|
|
@@ -18,10 +15,9 @@ class Config {
|
|
|
18
15
|
config.scope = rawConfig.scope;
|
|
19
16
|
config.key = rawConfig.key;
|
|
20
17
|
config.value = rawConfig.value;
|
|
21
|
-
config.inheritable =
|
|
22
|
-
config.sensitive =
|
|
23
|
-
config.state =
|
|
18
|
+
config.inheritable = Utils.isTrue(rawConfig.inheritable);
|
|
19
|
+
config.sensitive = Utils.isTrue(rawConfig.sensitive);
|
|
20
|
+
config.state = State.fromString(rawConfig.state);
|
|
24
21
|
return config;
|
|
25
22
|
}
|
|
26
23
|
}
|
|
27
|
-
exports.Config = Config;
|
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.ClientError = void 0;
|
|
4
|
-
const HttpClient_1 = require("../../Http/HttpClient");
|
|
5
|
-
class ClientError {
|
|
1
|
+
import { HttpClient } from '../../Http/HttpClient';
|
|
2
|
+
export class ClientError {
|
|
6
3
|
constructor(message, code = '') {
|
|
7
4
|
this.message = message;
|
|
8
5
|
this.code = code;
|
|
@@ -18,10 +15,10 @@ class ClientError {
|
|
|
18
15
|
else {
|
|
19
16
|
if (error.code !== null && error.code !== undefined) {
|
|
20
17
|
if (error.code === 'EUNAVAILABLE') {
|
|
21
|
-
clientError.code =
|
|
18
|
+
clientError.code = HttpClient.HTTP_UNAVAILABLE;
|
|
22
19
|
}
|
|
23
20
|
if (error.code === 'EAUTH') {
|
|
24
|
-
clientError.code =
|
|
21
|
+
clientError.code = HttpClient.HTTP_UNAUTHORIZED;
|
|
25
22
|
}
|
|
26
23
|
// if (error.code === 'ESTATUS' && error.message === 'HTTP status 503') {
|
|
27
24
|
// clientError.code = HttpClient.HTTP_UNAVAILABLE;
|
|
@@ -43,31 +40,30 @@ class ClientError {
|
|
|
43
40
|
return null;
|
|
44
41
|
break;
|
|
45
42
|
case 400:
|
|
46
|
-
return new ClientError('Bad Request',
|
|
43
|
+
return new ClientError('Bad Request', HttpClient.HTTP_BAD_REQUEST);
|
|
47
44
|
break;
|
|
48
45
|
case 401:
|
|
49
|
-
return new ClientError('Unauthorized',
|
|
46
|
+
return new ClientError('Unauthorized', HttpClient.HTTP_UNAUTHORIZED);
|
|
50
47
|
break;
|
|
51
48
|
case 404:
|
|
52
|
-
return new ClientError('Not Found',
|
|
49
|
+
return new ClientError('Not Found', HttpClient.HTTP_NOTFOUND);
|
|
53
50
|
break;
|
|
54
51
|
case 404:
|
|
55
|
-
return new ClientError('Unprocessable Entity',
|
|
52
|
+
return new ClientError('Unprocessable Entity', HttpClient.HTTP_UNPROCESSABLE_ENTITY);
|
|
56
53
|
break;
|
|
57
54
|
case 405:
|
|
58
|
-
return new ClientError('Not allowed',
|
|
55
|
+
return new ClientError('Not allowed', HttpClient.HTTP_NOT_ALLOWED);
|
|
59
56
|
break;
|
|
60
57
|
case 500:
|
|
61
|
-
return new ClientError('Internal Server Error',
|
|
58
|
+
return new ClientError('Internal Server Error', HttpClient.HTTP_NOTFOUND);
|
|
62
59
|
break;
|
|
63
60
|
case 503:
|
|
64
|
-
return new ClientError('Service not available',
|
|
61
|
+
return new ClientError('Service not available', HttpClient.HTTP_UNAVAILABLE);
|
|
65
62
|
break;
|
|
66
63
|
default:
|
|
67
64
|
console.error('Unknown status code "' + statusCode + '"', { code: statusCode, text: statusText });
|
|
68
|
-
return new ClientError('Status code ' + statusCode + ': ' + statusText,
|
|
65
|
+
return new ClientError('Status code ' + statusCode + ': ' + statusText, HttpClient.HTTP_ERROR);
|
|
69
66
|
}
|
|
70
67
|
return null;
|
|
71
68
|
}
|
|
72
69
|
}
|
|
73
|
-
exports.ClientError = ClientError;
|
|
@@ -1,11 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.EventType = void 0;
|
|
4
|
-
var EventType;
|
|
1
|
+
export var EventType;
|
|
5
2
|
(function (EventType) {
|
|
6
3
|
EventType[EventType["TaskExecutionRequested"] = "TaskExecutionRequested"] = "TaskExecutionRequested";
|
|
7
4
|
EventType[EventType["TaskExecutionStarted"] = "TaskExecutionStarted"] = "TaskExecutionStarted";
|
|
8
5
|
EventType[EventType["TaskExecutionFailed"] = "TaskExecutionFailed"] = "TaskExecutionFailed";
|
|
9
6
|
EventType[EventType["TaskExecutionComplete"] = "TaskExecutionComplete"] = "TaskExecutionComplete";
|
|
10
7
|
EventType[EventType["TaskExecutionRetry"] = "TaskExecutionRetry"] = "TaskExecutionRetry";
|
|
11
|
-
})(EventType
|
|
8
|
+
})(EventType || (EventType = {}));
|
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const HealthTestType_1 = require("./HealthTestType");
|
|
5
|
-
const HealthAlertStatus_1 = require("./HealthAlertStatus");
|
|
6
|
-
class HealthAlert {
|
|
1
|
+
import { HealthTestType } from './HealthTestType';
|
|
2
|
+
import { HealthAlertStatus } from './HealthAlertStatus';
|
|
3
|
+
export class HealthAlert {
|
|
7
4
|
constructor(healthTestType, status) {
|
|
8
5
|
this.data = [];
|
|
9
6
|
this.healthTestType = healthTestType;
|
|
@@ -12,7 +9,7 @@ class HealthAlert {
|
|
|
12
9
|
this.data = [];
|
|
13
10
|
}
|
|
14
11
|
static parse(raw) {
|
|
15
|
-
let log = new HealthAlert(
|
|
12
|
+
let log = new HealthAlert(HealthTestType.fromString(raw.healthTestType), HealthAlertStatus.fromString(raw.status));
|
|
16
13
|
log.date = new Date(raw.date);
|
|
17
14
|
log.data = raw.data;
|
|
18
15
|
return log;
|
|
@@ -26,4 +23,3 @@ class HealthAlert {
|
|
|
26
23
|
return null;
|
|
27
24
|
}
|
|
28
25
|
}
|
|
29
|
-
exports.HealthAlert = HealthAlert;
|
|
@@ -1,20 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.HealthAlertStatus = void 0;
|
|
4
|
-
const __1 = require("../..");
|
|
5
|
-
var HealthAlertStatus;
|
|
1
|
+
import { Utils } from '../../Utils';
|
|
2
|
+
export var HealthAlertStatus;
|
|
6
3
|
(function (HealthAlertStatus) {
|
|
7
4
|
HealthAlertStatus["PASSED"] = "pass";
|
|
8
5
|
HealthAlertStatus["SKIPPED"] = "skip";
|
|
9
6
|
HealthAlertStatus["FAILED"] = "fail";
|
|
10
|
-
})(HealthAlertStatus
|
|
7
|
+
})(HealthAlertStatus || (HealthAlertStatus = {}));
|
|
11
8
|
(function (HealthAlertStatus) {
|
|
12
9
|
function fromString(input) {
|
|
13
|
-
const result =
|
|
14
|
-
if (
|
|
10
|
+
const result = Utils.parseEnum(input, HealthAlertStatus);
|
|
11
|
+
if (Utils.isNullOrUndefined(result)) {
|
|
15
12
|
throw new Error('Unable to parse HealthAlertStatus from string: Unknown HealthAlertStatus "' + input + '"');
|
|
16
13
|
}
|
|
17
14
|
return result;
|
|
18
15
|
}
|
|
19
16
|
HealthAlertStatus.fromString = fromString;
|
|
20
|
-
})(HealthAlertStatus
|
|
17
|
+
})(HealthAlertStatus || (HealthAlertStatus = {}));
|
|
@@ -1,21 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.HealthTestType = void 0;
|
|
4
|
-
const __1 = require("../..");
|
|
5
|
-
var HealthTestType;
|
|
1
|
+
import { Utils } from '../../Utils';
|
|
2
|
+
export var HealthTestType;
|
|
6
3
|
(function (HealthTestType) {
|
|
7
4
|
HealthTestType["PROJECT_ENVIRONMENT_HAS_WORKERS"] = "project_environment_has_workers";
|
|
8
5
|
HealthTestType["QUEUE_FLOW_IS_HEALTHY"] = "queue_flow_is_healthy";
|
|
9
6
|
HealthTestType["WORKER_IS_UP_TO_DATE"] = "worker_is_up_to_date";
|
|
10
7
|
HealthTestType["TASK_EXECUTIONS_ARE_SUCCESSFUL"] = "task_executions_are_successful";
|
|
11
|
-
})(HealthTestType
|
|
8
|
+
})(HealthTestType || (HealthTestType = {}));
|
|
12
9
|
(function (HealthTestType) {
|
|
13
10
|
function fromString(input) {
|
|
14
|
-
const result =
|
|
15
|
-
if (
|
|
11
|
+
const result = Utils.parseEnum(input, HealthTestType);
|
|
12
|
+
if (Utils.isNullOrUndefined(result)) {
|
|
16
13
|
throw new Error('Unable to parse HealthTestType from string: Unknown HealthTestType "' + input + '"');
|
|
17
14
|
}
|
|
18
15
|
return result;
|
|
19
16
|
}
|
|
20
17
|
HealthTestType.fromString = fromString;
|
|
21
|
-
})(HealthTestType
|
|
18
|
+
})(HealthTestType || (HealthTestType = {}));
|