attlaz-client 1.7.0 → 1.7.3

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.
Files changed (125) hide show
  1. package/dist/Client.js +55 -59
  2. package/dist/Http/HttpClient.d.ts +0 -1
  3. package/dist/Http/HttpClient.js +27 -39
  4. package/dist/Http/HttpClientRequest.js +5 -9
  5. package/dist/Http/HttpClientRequest.spec.js +3 -5
  6. package/dist/Http/HttpClientResponse.js +1 -5
  7. package/dist/Http/OAuthClient.js +18 -22
  8. package/dist/Http/OAuthClient.spec.js +4 -6
  9. package/dist/Http/OAuthClientOptions.js +1 -5
  10. package/dist/Http/OAuthClientToken.js +1 -5
  11. package/dist/Model/Adapter/Adapter.js +1 -5
  12. package/dist/Model/Adapter/AdapterConfiguration.js +1 -5
  13. package/dist/Model/Adapter/AdapterConnection.js +4 -8
  14. package/dist/Model/Config.js +7 -11
  15. package/dist/Model/DataValue.js +1 -5
  16. package/dist/Model/DataValueCollection.js +6 -10
  17. package/dist/Model/Error/ClientError.js +13 -17
  18. package/dist/Model/Event/EventType.js +2 -5
  19. package/dist/Model/HealthAlert/HealthAlert.js +4 -8
  20. package/dist/Model/HealthAlert/HealthAlertStatus.js +5 -8
  21. package/dist/Model/HealthAlert/HealthTestType.js +5 -8
  22. package/dist/Model/JsonSerializable.js +1 -5
  23. package/dist/Model/Log/Log.js +11 -15
  24. package/dist/Model/Log/LogLevel.js +5 -8
  25. package/dist/Model/Log/LogQuery.js +1 -5
  26. package/dist/Model/Log/LogStatus.js +5 -8
  27. package/dist/Model/Log/LogStreamId.js +1 -5
  28. package/dist/Model/Messaging/Channel/Channel.js +8 -12
  29. package/dist/Model/Messaging/Channel/ChannelData.js +1 -5
  30. package/dist/Model/Messaging/Channel/ChannelType.js +5 -8
  31. package/dist/Model/Messaging/Channel/EmailChannelData.js +4 -8
  32. package/dist/Model/Messaging/Channel/PushChannelData.js +4 -8
  33. package/dist/Model/Messaging/Channel/SlackChannelData.js +4 -8
  34. package/dist/Model/Messaging/Channel/SmsChannelData.js +4 -8
  35. package/dist/Model/Messaging/Channel/WebhookChannelData.js +4 -8
  36. package/dist/Model/Messaging/ChannelHistory.js +3 -7
  37. package/dist/Model/Messaging/Subscriber.js +6 -10
  38. package/dist/Model/Notification.js +1 -5
  39. package/dist/Model/PagedResult.js +1 -5
  40. package/dist/Model/Project/PlatformLanguage.js +4 -8
  41. package/dist/Model/Project/Project.js +4 -8
  42. package/dist/Model/Project/ProjectDeploy.js +8 -12
  43. package/dist/Model/Project/ProjectDeployCommit.js +1 -5
  44. package/dist/Model/Project/ProjectDeployStatus.js +5 -8
  45. package/dist/Model/Project/ProjectEnvironment.js +6 -10
  46. package/dist/Model/Queue/QueueStatus.js +1 -5
  47. package/dist/Model/Result/DataResult.js +1 -5
  48. package/dist/Model/Result/DataResult.spec.js +2 -4
  49. package/dist/Model/Result/DataResultCollection.js +1 -5
  50. package/dist/Model/Result/ResultError.js +1 -5
  51. package/dist/Model/SourcesAccount.js +1 -5
  52. package/dist/Model/SourcesAccountRepository.js +1 -5
  53. package/dist/Model/State.js +5 -8
  54. package/dist/Model/StateAware.js +1 -2
  55. package/dist/Model/Storage/StorageInformation.js +1 -5
  56. package/dist/Model/Storage/StorageType.js +5 -8
  57. package/dist/Model/Task.js +4 -8
  58. package/dist/Model/TaskExecution/TaskExecutionStats.js +1 -5
  59. package/dist/Model/TaskExecution.js +1 -5
  60. package/dist/Model/TaskExecutionHistory.js +3 -7
  61. package/dist/Model/TaskExecutionResponse.js +1 -5
  62. package/dist/Model/TaskExecutionStatus.js +5 -8
  63. package/dist/Model/TaskExecutionSummary.js +7 -11
  64. package/dist/Model/TaskSummary.js +8 -12
  65. package/dist/Model/Team/Team.js +1 -5
  66. package/dist/Model/Team/TeamMember.js +1 -5
  67. package/dist/Model/Team/TeamMemberInvite.js +3 -7
  68. package/dist/Model/Team/TeamMemberInvite2.js +1 -5
  69. package/dist/Model/Team/TeamMemberInviteState.js +5 -8
  70. package/dist/Model/Team/TeamMemberRole.js +5 -8
  71. package/dist/Model/Trigger/ApiTrigger.js +4 -8
  72. package/dist/Model/Trigger/ApiTriggerData.js +2 -6
  73. package/dist/Model/Trigger/ScheduleTrigger.js +4 -8
  74. package/dist/Model/Trigger/ScheduleTriggerData.js +2 -6
  75. package/dist/Model/Trigger/Trigger.js +15 -19
  76. package/dist/Model/Trigger/TriggerData.js +1 -5
  77. package/dist/Model/Trigger/TriggerType.js +5 -8
  78. package/dist/Model/Trigger/WebhookTrigger.js +4 -8
  79. package/dist/Model/Trigger/WebhookTriggerData.js +2 -6
  80. package/dist/Model/User/UserAuthProvider.js +6 -10
  81. package/dist/Model/User.js +6 -10
  82. package/dist/Model/Worker/Platform.js +8 -12
  83. package/dist/Model/Worker/PlatformImage.js +6 -10
  84. package/dist/Model/Worker/Worker.js +7 -11
  85. package/dist/Model/Worker/WorkerConfig.js +1 -5
  86. package/dist/Model/Worker/WorkerInstance.js +3 -7
  87. package/dist/Model/Worker/WorkerInstanceState.js +5 -8
  88. package/dist/Model/Worker/WorkerState.js +5 -8
  89. package/dist/Service/AdapterEndpoint.js +11 -15
  90. package/dist/Service/ChannelEndpoint.js +11 -15
  91. package/dist/Service/ConfigEndpoint.js +8 -12
  92. package/dist/Service/Endpoint.js +3 -7
  93. package/dist/Service/HealthAlertEndpoint.js +4 -8
  94. package/dist/Service/LogEndpoint.js +15 -19
  95. package/dist/Service/NotificationsEndpoint.js +4 -8
  96. package/dist/Service/PlatformEndpoint.js +6 -10
  97. package/dist/Service/PlatformLanguageEndpoint.js +4 -8
  98. package/dist/Service/ProjectDeployEndpoint.js +7 -11
  99. package/dist/Service/ProjectEndpoint.js +9 -13
  100. package/dist/Service/ProjectEnvironmentEndpoint.js +2 -6
  101. package/dist/Service/QueueEndpoint.js +6 -10
  102. package/dist/Service/SourcesAccountEndpoint.js +8 -12
  103. package/dist/Service/StorageEndpoint.js +2 -6
  104. package/dist/Service/SubscriberEndpoint.js +7 -11
  105. package/dist/Service/TaskEndpoint.js +14 -18
  106. package/dist/Service/TaskExecutionEndpoint.d.ts +1 -1
  107. package/dist/Service/TaskExecutionEndpoint.js +16 -20
  108. package/dist/Service/TaskExecutionRequestEndpoint.js +2 -6
  109. package/dist/Service/TaskExecutionStatsEndpoint.js +4 -8
  110. package/dist/Service/TeamMemberEndpoint.js +14 -18
  111. package/dist/Service/TeamsEndpoint.js +6 -10
  112. package/dist/Service/TriggerEndpoint.js +9 -13
  113. package/dist/Service/UserEndpoint.js +10 -14
  114. package/dist/Service/WorkerConfigEndpoint.js +7 -11
  115. package/dist/Service/WorkerEndpoint.js +7 -11
  116. package/dist/Utils.js +1 -5
  117. package/dist/Utils.spec.js +32 -34
  118. package/dist/auth.spec.js +22 -24
  119. package/dist/data.spec.js +3 -5
  120. package/dist/index.d.ts +1 -0
  121. package/dist/index.js +106 -215
  122. package/dist/test.js +11 -13
  123. package/dist/version.d.ts +1 -1
  124. package/dist/version.js +1 -4
  125. package/package.json +4 -3
package/dist/Client.js CHANGED
@@ -1,34 +1,31 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Client = void 0;
4
- const WorkerEndpoint_1 = require("./Service/WorkerEndpoint");
5
- const AdapterEndpoint_1 = require("./Service/AdapterEndpoint");
6
- const ProjectEnvironmentEndpoint_1 = require("./Service/ProjectEnvironmentEndpoint");
7
- const ProjectEndpoint_1 = require("./Service/ProjectEndpoint");
8
- const TaskExecutionRequestEndpoint_1 = require("./Service/TaskExecutionRequestEndpoint");
9
- const OAuthClient_1 = require("./Http/OAuthClient");
10
- const WorkerConfigEndpoint_1 = require("./Service/WorkerConfigEndpoint");
11
- const TeamsEndpoint_1 = require("./Service/TeamsEndpoint");
12
- const UserEndpoint_1 = require("./Service/UserEndpoint");
13
- const ConfigEndpoint_1 = require("./Service/ConfigEndpoint");
14
- const SubscriberEndpoint_1 = require("./Service/SubscriberEndpoint");
15
- const TaskEndpoint_1 = require("./Service/TaskEndpoint");
16
- const TeamMemberEndpoint_1 = require("./Service/TeamMemberEndpoint");
17
- const StorageEndpoint_1 = require("./Service/StorageEndpoint");
18
- const QueueEndpoint_1 = require("./Service/QueueEndpoint");
19
- const NotificationsEndpoint_1 = require("./Service/NotificationsEndpoint");
20
- const ProjectDeployEndpoint_1 = require("./Service/ProjectDeployEndpoint");
21
- const SourcesAccountEndpoint_1 = require("./Service/SourcesAccountEndpoint");
22
- const OAuthClientOptions_1 = require("./Http/OAuthClientOptions");
23
- const PlatformLanguageEndpoint_1 = require("./Service/PlatformLanguageEndpoint");
24
- const ChannelEndpoint_1 = require("./Service/ChannelEndpoint");
25
- const HealthAlertEndpoint_1 = require("./Service/HealthAlertEndpoint");
26
- const TaskExecutionEndpoint_1 = require("./Service/TaskExecutionEndpoint");
27
- const LogEndpoint_1 = require("./Service/LogEndpoint");
28
- const TriggerEndpoint_1 = require("./Service/TriggerEndpoint");
29
- const PlatformEndpoint_1 = require("./Service/PlatformEndpoint");
30
- const TaskExecutionStatsEndpoint_1 = require("./Service/TaskExecutionStatsEndpoint");
31
- class Client {
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 { PlatformLanguageEndpoint } from './Service/PlatformLanguageEndpoint';
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
+ import { PlatformEndpoint } from './Service/PlatformEndpoint';
27
+ import { TaskExecutionStatsEndpoint } from './Service/TaskExecutionStatsEndpoint';
28
+ export class Client {
32
29
  // private test: Map<string, any>;
33
30
  // private socketService;
34
31
  constructor(apiEndpoint, clientId, clientSecret) {
@@ -36,34 +33,34 @@ class Client {
36
33
  this.clientId = clientId;
37
34
  this.clientSecret = clientSecret;
38
35
  this.Store = {
39
- WorkerEndpoint: WorkerEndpoint_1.WorkerEndpoint,
40
- AdapterEndpoint: AdapterEndpoint_1.AdapterEndpoint,
41
- ProjectEndpoint: ProjectEndpoint_1.ProjectEndpoint,
42
- ProjectEnvironmentEndpoint: ProjectEnvironmentEndpoint_1.ProjectEnvironmentEndpoint,
43
- ProjectDeployEndpoint: ProjectDeployEndpoint_1.ProjectDeployEndpoint,
44
- QueueEndpoint: QueueEndpoint_1.QueueEndpoint,
45
- ChannelEndpoint: ChannelEndpoint_1.ChannelEndpoint,
46
- ConfigEndpoint: ConfigEndpoint_1.ConfigEndpoint,
47
- NotificationsEndpoint: NotificationsEndpoint_1.NotificationsEndpoint,
48
- SubscriberEndpoint: SubscriberEndpoint_1.SubscriberEndpoint,
49
- LogEndpoint: LogEndpoint_1.LogEndpoint,
50
- TaskEndpoint: TaskEndpoint_1.TaskEndpoint,
51
- TaskExecutionEndpoint: TaskExecutionEndpoint_1.TaskExecutionEndpoint,
52
- TaskExecutionRequestEndpoint: TaskExecutionRequestEndpoint_1.TaskExecutionRequestEndpoint,
53
- TeamsEndpoint: TeamsEndpoint_1.TeamsEndpoint,
54
- TriggerEndpoint: TriggerEndpoint_1.TriggerEndpoint,
55
- UserEndpoint: UserEndpoint_1.UserEndpoint,
56
- MemberEndpoint: TeamMemberEndpoint_1.TeamMemberEndpoint,
57
- SourcesAccountEndpoint: SourcesAccountEndpoint_1.SourcesAccountEndpoint,
58
- LanguageEndpoint: PlatformLanguageEndpoint_1.PlatformLanguageEndpoint,
59
- StorageEndpoint: StorageEndpoint_1.StorageEndpoint,
60
- WorkerConfigEndpoint: WorkerConfigEndpoint_1.WorkerConfigEndpoint,
61
- HealthAlertEndpoint: HealthAlertEndpoint_1.HealthAlertEndpoint,
62
- PlatformEndpoint: PlatformEndpoint_1.PlatformEndpoint,
63
- TaskExecutionStatsEndpoint: TaskExecutionStatsEndpoint_1.TaskExecutionStatsEndpoint
36
+ WorkerEndpoint,
37
+ AdapterEndpoint,
38
+ ProjectEndpoint,
39
+ ProjectEnvironmentEndpoint,
40
+ ProjectDeployEndpoint,
41
+ QueueEndpoint,
42
+ ChannelEndpoint,
43
+ ConfigEndpoint,
44
+ NotificationsEndpoint,
45
+ SubscriberEndpoint,
46
+ LogEndpoint,
47
+ TaskEndpoint,
48
+ TaskExecutionEndpoint,
49
+ TaskExecutionRequestEndpoint,
50
+ TeamsEndpoint,
51
+ TriggerEndpoint,
52
+ UserEndpoint,
53
+ MemberEndpoint: TeamMemberEndpoint,
54
+ SourcesAccountEndpoint,
55
+ LanguageEndpoint: PlatformLanguageEndpoint,
56
+ StorageEndpoint,
57
+ WorkerConfigEndpoint,
58
+ HealthAlertEndpoint,
59
+ PlatformEndpoint,
60
+ TaskExecutionStatsEndpoint
64
61
  };
65
- const options = new OAuthClientOptions_1.OAuthClientOptions(apiEndpoint, clientId, clientSecret);
66
- this.httpClient = new OAuthClient_1.OAuthClient(options);
62
+ const options = new OAuthClientOptions(apiEndpoint, clientId, clientSecret);
63
+ this.httpClient = new OAuthClient(options);
67
64
  this.endpoints = new Map();
68
65
  // this.test = new Map<string, any>();
69
66
  //
@@ -200,4 +197,3 @@ class Client {
200
197
  return this.endpoints.get(key);
201
198
  }
202
199
  }
203
- exports.Client = Client;
@@ -10,7 +10,6 @@ export declare class HttpClient {
10
10
  static HTTP_INTERNAL_SERVER_ERROR: number;
11
11
  static HTTP_BAD_GATEWAY: number;
12
12
  static HTTP_UNAVAILABLE: number;
13
- static get(url: string, requestData?: any): Promise<any>;
14
13
  static request2(request: HttpClientRequest): Promise<HttpClientResponse>;
15
14
  private static getContentType;
16
15
  private static formatContentType;
@@ -1,27 +1,28 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.HttpClient = void 0;
4
- const popsicle_1 = require("popsicle");
5
- const Utils_1 = require("../Utils");
6
- const HttpClientResponse_1 = require("./HttpClientResponse");
7
- const ClientError_1 = require("../Model/Error/ClientError");
8
- const version_1 = require("../version");
9
- class HttpClient {
10
- static async get(url, requestData = {}) {
11
- if (Utils_1.Utils.isNullOrUndefined(requestData)) {
12
- requestData = {};
13
- }
14
- const response = await (0, popsicle_1.fetch)(url, requestData);
15
- //TODO: validate status
16
- const error = ClientError_1.ClientError.byStatus(response.status, response.statusText);
17
- if (!Utils_1.Utils.isNullOrUndefined(error)) {
18
- throw error;
19
- }
20
- // TODO: make it possible to do request without parsing the json
21
- return await response.json();
22
- }
1
+ import { fetch } from 'popsicle';
2
+ import { HttpClientResponse } from './HttpClientResponse';
3
+ import { ClientError } from '../Model/Error/ClientError';
4
+ import { VERSION } from '../version';
5
+ export class HttpClient {
6
+ // public static async get(url: string, requestData: any = {}): Promise<any> {
7
+ // if (Utils.isNullOrUndefined(requestData)) {
8
+ // requestData = {};
9
+ // }
10
+ // const response: Response = await fetch(url, requestData);
11
+ //
12
+ // //TODO: validate status
13
+ // const error: ClientError | null = ClientError.byStatus(response.status, response.statusText);
14
+ // if (!Utils.isNullOrUndefined(error)) {
15
+ // throw error;
16
+ // }
17
+ //
18
+ // // TODO: make it possible to do request without parsing the json
19
+ // return await response.json();
20
+ // }
23
21
  static async request2(request) {
24
- request.headers['User-Agent'] = 'Attlaz Http/' + version_1.VERSION;
22
+ if (typeof window === 'undefined') {
23
+ // Add user agent when running in Node
24
+ request.headers['User-Agent'] = 'Attlaz Http/' + VERSION;
25
+ }
25
26
  const rawRequest = {
26
27
  url: request.getFullUrl(),
27
28
  method: request.method,
@@ -29,8 +30,8 @@ class HttpClient {
29
30
  omitDefaultHeaders: true,
30
31
  body: request.body
31
32
  };
32
- const response = await (0, popsicle_1.fetch)(request.getFullUrl(), rawRequest);
33
- const httpResponse = new HttpClientResponse_1.HttpClientResponse(response.status, response.statusText);
33
+ const response = await fetch(request.getFullUrl(), rawRequest);
34
+ const httpResponse = new HttpClientResponse(response.status, response.statusText);
34
35
  let contentType = this.getContentType(response);
35
36
  const rawData = await response.text();
36
37
  if (contentType.type === 'application/json') {
@@ -47,23 +48,11 @@ class HttpClient {
47
48
  else {
48
49
  httpResponse.body = rawData;
49
50
  }
50
- const error = ClientError_1.ClientError.byStatus(response.status, response.statusText);
51
+ const error = ClientError.byStatus(response.status, response.statusText);
51
52
  if (error !== null && error !== undefined) {
52
53
  error.body = httpResponse.body;
53
54
  throw error;
54
55
  }
55
- // //TODO: validate status
56
- //
57
- // const error: ClientError = ClientError.byStatus(response.status, response.statusText);
58
- // if (!Utils.isNullOrUndefined(error)) {
59
- //
60
- // // const body: string = await response.text();
61
- // // console.log('Text' + body);
62
- // //
63
- // // console.log(response);
64
- // throw error;
65
- // }
66
- //
67
56
  return httpResponse;
68
57
  }
69
58
  static getContentType(response) {
@@ -87,7 +76,6 @@ class HttpClient {
87
76
  return { type: input, options: null };
88
77
  }
89
78
  }
90
- exports.HttpClient = HttpClient;
91
79
  HttpClient.HTTP_BAD_REQUEST = 400;
92
80
  HttpClient.HTTP_UNAUTHORIZED = 401;
93
81
  HttpClient.HTTP_FORBIDDEN = 403;
@@ -1,9 +1,6 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.HttpClientRequest = void 0;
4
- const Utils_1 = require("../Utils");
5
- const JsonSerializable_1 = require("../Model/JsonSerializable");
6
- class HttpClientRequest {
1
+ import { Utils } from '../Utils';
2
+ import { JsonSerializable } from '../Model/JsonSerializable';
3
+ export class HttpClientRequest {
7
4
  constructor(url, method = HttpClientRequest.GET) {
8
5
  this.headers = {};
9
6
  this.body = null;
@@ -14,7 +11,7 @@ class HttpClientRequest {
14
11
  this.setHeader('Content-Type', 'application/json');
15
12
  }
16
13
  setBasicAuth(user, password) {
17
- this.setHeader('Authorization', 'Basic ' + Utils_1.Utils.base64encode(user + ':' + password));
14
+ this.setHeader('Authorization', 'Basic ' + Utils.base64encode(user + ':' + password));
18
15
  }
19
16
  setHeader(key, value) {
20
17
  this.headers[key] = value;
@@ -24,7 +21,7 @@ class HttpClientRequest {
24
21
  }
25
22
  setJsonBody(data) {
26
23
  this.setJsonHeader();
27
- this.body = JsonSerializable_1.JsonSerializable.stringify(data);
24
+ this.body = JsonSerializable.stringify(data);
28
25
  }
29
26
  getFullUrl() {
30
27
  let result = this.urlObj.href;
@@ -35,7 +32,6 @@ class HttpClientRequest {
35
32
  return result;
36
33
  }
37
34
  }
38
- exports.HttpClientRequest = HttpClientRequest;
39
35
  HttpClientRequest.GET = 'GET';
40
36
  HttpClientRequest.POST = 'POST';
41
37
  HttpClientRequest.PUT = 'PUT';
@@ -1,14 +1,12 @@
1
- "use strict";
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 HttpClientRequest_1.HttpClientRequest('https://example.com');
3
+ const request = new HttpClientRequest('https://example.com');
6
4
  expect(request.getFullUrl()).toBe('https://example.com');
7
5
  request.addQueryParam('queryparam1', 'queryparam1value');
8
6
  expect(request.getFullUrl()).toBe('https://example.com?queryparam1=queryparam1value');
9
7
  });
10
8
  test('Test query string - add to existing query string', async () => {
11
- const request = new HttpClientRequest_1.HttpClientRequest('https://example.com?queryparam0=queryparam0value');
9
+ const request = new HttpClientRequest('https://example.com?queryparam0=queryparam0value');
12
10
  expect(request.getFullUrl()).toBe('https://example.com?queryparam0=queryparam0value');
13
11
  request.addQueryParam('queryparam1', 'queryparam1value');
14
12
  expect(request.getFullUrl()).toBe('https://example.com?queryparam0=queryparam0value&queryparam1=queryparam1value');
@@ -1,11 +1,7 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.HttpClientResponse = void 0;
4
- class HttpClientResponse {
1
+ export class HttpClientResponse {
5
2
  constructor(status, statusText) {
6
3
  this.body = null;
7
4
  this.status = status;
8
5
  this.statusText = statusText;
9
6
  }
10
7
  }
11
- exports.HttpClientResponse = HttpClientResponse;
@@ -1,13 +1,10 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.OAuthClient = void 0;
4
- const ClientError_1 = require("../Model/Error/ClientError");
5
- const HttpClient_1 = require("./HttpClient");
6
- const HttpClientRequest_1 = require("./HttpClientRequest");
7
- const OAuthClientToken_1 = require("./OAuthClientToken");
8
- const ClientOAuth2 = require("client-oauth2");
9
- const JsonSerializable_1 = require("../Model/JsonSerializable");
10
- class OAuthClient {
1
+ import { ClientError } from '../Model/Error/ClientError';
2
+ import { HttpClient } from './HttpClient';
3
+ import { HttpClientRequest } from './HttpClientRequest';
4
+ import { OAuthClientToken } from './OAuthClientToken';
5
+ import * as ClientOAuth2 from 'client-oauth2';
6
+ import { JsonSerializable } from '../Model/JsonSerializable';
7
+ export class OAuthClient {
11
8
  constructor(options) {
12
9
  this.debug = false;
13
10
  this.oauthToken = null;
@@ -42,7 +39,7 @@ class OAuthClient {
42
39
  }
43
40
  catch (e) {
44
41
  console.log(e);
45
- throw ClientError_1.ClientError.fromError(e);
42
+ throw ClientError.fromError(e);
46
43
  }
47
44
  }
48
45
  async refreshToken() {
@@ -55,7 +52,7 @@ class OAuthClient {
55
52
  this.oathClientToken = this.tokenToOauthClientToken(this.oauthToken);
56
53
  }
57
54
  catch (e) {
58
- const error = ClientError_1.ClientError.fromError(e);
55
+ const error = ClientError.fromError(e);
59
56
  throw error;
60
57
  }
61
58
  }
@@ -71,12 +68,12 @@ class OAuthClient {
71
68
  }
72
69
  async request(action, parameters = null, method = 'GET', signWithOauthToken = true) {
73
70
  if (signWithOauthToken && !this.isAuthenticated()) {
74
- throw new ClientError_1.ClientError('Unable to perform request, access token not provided');
71
+ throw new ClientError('Unable to perform request, access token not provided');
75
72
  }
76
73
  else {
77
74
  if (signWithOauthToken) {
78
75
  if (this.oauthToken === null) {
79
- throw new ClientError_1.ClientError('Unable to perform request, access token not provided');
76
+ throw new ClientError('Unable to perform request, access token not provided');
80
77
  }
81
78
  if (signWithOauthToken && this.oauthToken.expired()) {
82
79
  await this.refreshToken();
@@ -87,14 +84,14 @@ class OAuthClient {
87
84
  console.debug('[Client] REQ: ' + requestData.method.toUpperCase() + ' ' + requestData.getFullUrl());
88
85
  }
89
86
  try {
90
- const response = await HttpClient_1.HttpClient.request2(requestData);
87
+ const response = await HttpClient.request2(requestData);
91
88
  // if (this.debug) {
92
89
  // console.info('[Client response] ', {body: response.body});
93
90
  // }
94
91
  return response.body;
95
92
  }
96
93
  catch (error) {
97
- const clientError = ClientError_1.ClientError.fromError(error);
94
+ const clientError = ClientError.fromError(error);
98
95
  if (this.debug) {
99
96
  console.error('[Client] Error:', { error, clientError });
100
97
  }
@@ -146,7 +143,7 @@ class OAuthClient {
146
143
  return this.oauthClient.token.getUri(options === null ? undefined : options);
147
144
  }
148
145
  tokenToOauthClientToken(oauthToken) {
149
- const token = new OAuthClientToken_1.OAuthClientToken(oauthToken.accessToken, oauthToken.tokenType, oauthToken.refreshToken, oauthToken.data.scopes);
146
+ const token = new OAuthClientToken(oauthToken.accessToken, oauthToken.tokenType, oauthToken.refreshToken, oauthToken.data.scopes);
150
147
  const rawTokenExpires = oauthToken.expires;
151
148
  if (rawTokenExpires !== null && rawTokenExpires !== undefined) {
152
149
  token.expires = rawTokenExpires;
@@ -161,10 +158,10 @@ class OAuthClient {
161
158
  }
162
159
  createRequestData(action, parameters = null, method = 'GET', signWithOauthToken = true) {
163
160
  const url = this.getUri(action);
164
- let requestData = new HttpClientRequest_1.HttpClientRequest(url, method);
161
+ let requestData = new HttpClientRequest(url, method);
165
162
  if ((method === 'POST' || method === 'DELETE' || method === 'PUT') && parameters !== null && parameters !== undefined) {
166
163
  if (typeof parameters === 'object') {
167
- parameters = JsonSerializable_1.JsonSerializable.stringify(parameters);
164
+ parameters = JsonSerializable.stringify(parameters);
168
165
  }
169
166
  else if (typeof parameters === 'string') {
170
167
  }
@@ -182,7 +179,7 @@ class OAuthClient {
182
179
  }
183
180
  if (signWithOauthToken) {
184
181
  if (this.oauthToken === null) {
185
- throw new ClientError_1.ClientError('Unable to perform request, access token not provided');
182
+ throw new ClientError('Unable to perform request, access token not provided');
186
183
  }
187
184
  if (this.oauthToken.expired()) {
188
185
  throw new Error('Unable to sign request, token is expired');
@@ -195,7 +192,7 @@ class OAuthClient {
195
192
  }
196
193
  signRequest(requestObject) {
197
194
  if (this.oathClientToken === null) {
198
- throw new ClientError_1.ClientError('Unable to sign request, access token not provided');
195
+ throw new ClientError('Unable to sign request, access token not provided');
199
196
  }
200
197
  const tokenType = this.oathClientToken.token_type;
201
198
  const accessToken = this.oathClientToken.access_token;
@@ -212,4 +209,3 @@ class OAuthClient {
212
209
  return requestObject;
213
210
  }
214
211
  }
215
- exports.OAuthClient = OAuthClient;
@@ -1,10 +1,8 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
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 OAuthClientOptions_1.OAuthClientOptions('https://github.com/login', '3b938da6f58d6bef7d59', 'da05698a6bd449de9437e11ff0b99003f511e40f');
7
- const client = new OAuthClient_1.OAuthClient(options);
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
- "use strict";
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
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.OAuthClientToken = void 0;
4
- class OAuthClientToken {
1
+ export class OAuthClientToken {
5
2
  constructor(access_token, token_type, refresh_token, scope) {
6
3
  this.access_token = '';
7
4
  this.token_type = '';
@@ -33,4 +30,3 @@ class OAuthClientToken {
33
30
  return token;
34
31
  }
35
32
  }
36
- exports.OAuthClientToken = OAuthClientToken;
@@ -1,7 +1,4 @@
1
- "use strict";
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
- "use strict";
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,10 +1,7 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.AdapterConnection = void 0;
4
- const DataValueCollection_1 = require("../DataValueCollection");
5
- class AdapterConnection {
1
+ import { DataValueCollection } from '../DataValueCollection';
2
+ export class AdapterConnection {
6
3
  constructor() {
7
- this.configuration = new DataValueCollection_1.DataValueCollection();
4
+ this.configuration = new DataValueCollection();
8
5
  }
9
6
  static parse(rawAdapterConnection) {
10
7
  let adapterConnection = new AdapterConnection();
@@ -12,7 +9,7 @@ class AdapterConnection {
12
9
  adapterConnection.key = rawAdapterConnection.key;
13
10
  adapterConnection.adapter = rawAdapterConnection.adapter;
14
11
  adapterConnection.name = rawAdapterConnection.name;
15
- adapterConnection.configuration = DataValueCollection_1.DataValueCollection.fromObject(rawAdapterConnection.configuration);
12
+ adapterConnection.configuration = DataValueCollection.fromObject(rawAdapterConnection.configuration);
16
13
  return adapterConnection;
17
14
  // adapter.id = rawAdapter.id;
18
15
  // adapter.name = rawAdapter.name;
@@ -23,4 +20,3 @@ class AdapterConnection {
23
20
  // return adapter;
24
21
  }
25
22
  }
26
- exports.AdapterConnection = AdapterConnection;
@@ -1,13 +1,10 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Config = void 0;
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 = State_1.State.Active;
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 = Utils_1.Utils.isTrue(rawConfig.inheritable);
22
- config.sensitive = Utils_1.Utils.isTrue(rawConfig.sensitive);
23
- config.state = State_1.State.fromString(rawConfig.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,10 +1,6 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.DataValue = void 0;
4
- class DataValue {
1
+ export class DataValue {
5
2
  constructor(key, value) {
6
3
  this.key = key;
7
4
  this.value = value;
8
5
  }
9
6
  }
10
- exports.DataValue = DataValue;
@@ -1,10 +1,7 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.DataValueCollection = void 0;
4
- const DataValue_1 = require("./DataValue");
5
- const Utils_1 = require("../Utils");
6
- const JsonSerializable_1 = require("./JsonSerializable");
7
- class DataValueCollection extends JsonSerializable_1.JsonSerializable {
1
+ import { DataValue } from './DataValue';
2
+ import { Utils } from '../Utils';
3
+ import { JsonSerializable } from './JsonSerializable';
4
+ export class DataValueCollection extends JsonSerializable {
8
5
  constructor() {
9
6
  super(...arguments);
10
7
  this._values = [];
@@ -13,7 +10,7 @@ class DataValueCollection extends JsonSerializable_1.JsonSerializable {
13
10
  return this._values.length;
14
11
  }
15
12
  static fromObject(rawValues) {
16
- if (Utils_1.Utils.isNullOrUndefined(rawValues)) {
13
+ if (Utils.isNullOrUndefined(rawValues)) {
17
14
  return new DataValueCollection();
18
15
  }
19
16
  const result = new DataValueCollection();
@@ -30,7 +27,7 @@ class DataValueCollection extends JsonSerializable_1.JsonSerializable {
30
27
  if (existingIndex !== -1) {
31
28
  this._values.splice(existingIndex);
32
29
  }
33
- this._values.push(new DataValue_1.DataValue(key, value));
30
+ this._values.push(new DataValue(key, value));
34
31
  }
35
32
  get(key) {
36
33
  for (const tag of this._values) {
@@ -58,4 +55,3 @@ class DataValueCollection extends JsonSerializable_1.JsonSerializable {
58
55
  return this._values;
59
56
  }
60
57
  }
61
- exports.DataValueCollection = DataValueCollection;