attlaz-client 1.8.23 → 1.8.25

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.
@@ -11,6 +11,7 @@ export declare class ProjectDeploy {
11
11
  status: ProjectDeployStatus;
12
12
  bytes: number;
13
13
  commits: ProjectDeployCommit[];
14
+ path: string;
14
15
  commitHash: string;
15
16
  errors: {
16
17
  message: string;
@@ -12,7 +12,7 @@ class ProjectDeploy {
12
12
  }
13
13
  static parse(rawProjectDeploy) {
14
14
  const projectDeploy = new ProjectDeploy();
15
- projectDeploy.id = rawProjectDeploy.id;
15
+ projectDeploy.id = rawProjectDeploy.id.toString();
16
16
  projectDeploy.projectEnvironmentId = rawProjectDeploy.projectEnvironmentId;
17
17
  projectDeploy.userId = rawProjectDeploy.userId;
18
18
  projectDeploy.requested = new Date(rawProjectDeploy.requested);
@@ -22,6 +22,7 @@ class ProjectDeploy {
22
22
  if (!Utils_1.Utils.isNullOrUndefined(rawProjectDeploy.bytes)) {
23
23
  projectDeploy.bytes = parseInt(rawProjectDeploy.bytes);
24
24
  }
25
+ projectDeploy.path = rawProjectDeploy.path;
25
26
  projectDeploy.commitHash = rawProjectDeploy.commit_hash;
26
27
  const rawProjectDeployCommits = rawProjectDeploy.commits;
27
28
  for (let rawProjectDeployCommit of rawProjectDeployCommits) {
@@ -12,7 +12,7 @@ class ProjectEnvironment {
12
12
  }
13
13
  static parse(rawProjectEnvironment) {
14
14
  const projectEnvironment = new ProjectEnvironment();
15
- projectEnvironment.id = rawProjectEnvironment.id;
15
+ projectEnvironment.id = rawProjectEnvironment.id.toString();
16
16
  projectEnvironment.key = rawProjectEnvironment.key;
17
17
  if (rawProjectEnvironment.project !== undefined) {
18
18
  projectEnvironment.projectId = rawProjectEnvironment.project;
@@ -1,7 +1,7 @@
1
1
  import { Endpoint } from './Endpoint';
2
2
  import { ProjectDeploy } from '../Model/Project/ProjectDeploy';
3
3
  export declare class ProjectDeployEndpoint extends Endpoint {
4
- getById(deployId: string): Promise<ProjectDeploy>;
4
+ getById(deployId: string): Promise<ProjectDeploy | null>;
5
5
  getByCodeSource(codeSourceId: string): Promise<ProjectDeploy[]>;
6
6
  requestDeploy(codeSourceId: string): Promise<any>;
7
7
  }
@@ -4,16 +4,20 @@ exports.ProjectDeployEndpoint = void 0;
4
4
  const Endpoint_1 = require("./Endpoint");
5
5
  const ProjectDeploy_1 = require("../Model/Project/ProjectDeploy");
6
6
  const Utils_1 = require("../Utils");
7
+ const HttpClient_1 = require("../Http/HttpClient");
7
8
  class ProjectDeployEndpoint extends Endpoint_1.Endpoint {
8
9
  async getById(deployId) {
9
10
  try {
10
11
  const rawProjectDeploy = await this.httpClient.request('/deploys/' + deployId);
11
12
  if (Utils_1.Utils.isNullOrUndefined(rawProjectDeploy)) {
12
- throw new Error('Unable to get deploy');
13
+ return null;
13
14
  }
14
15
  return ProjectDeploy_1.ProjectDeploy.parse(rawProjectDeploy);
15
16
  }
16
17
  catch (error) {
18
+ if (error.code === HttpClient_1.HttpClient.HTTP_NOTFOUND) {
19
+ return null;
20
+ }
17
21
  if (this.httpClient.isDebugEnabled()) {
18
22
  console.error('Failed to load project deploy by id', error);
19
23
  }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const Client_1 = require("../Client");
4
+ jest.setTimeout((60) * 1000);
5
+ const apiEndpoint = 'http://localhost:5728/';
6
+ // const apiEndpoint: string = 'https://api2.attlaz.com';
7
+ const clientCredentialClientId = 'zSGdVWE3FAS8kY5C';
8
+ const clientCredentialClientSecret = '6jhYgFPAUm9HmCus';
9
+ test('Test get project deploy', async () => {
10
+ expect.assertions(3);
11
+ let client = new Client_1.Client(apiEndpoint, clientCredentialClientId, clientCredentialClientSecret);
12
+ client.getHttpClient().enableDebug();
13
+ await client.authenticate();
14
+ const existingProjectDeploy = await client.getProjectDeployEndpoint().getById('5');
15
+ expect(existingProjectDeploy).not.toBeNull();
16
+ expect(existingProjectDeploy === null || existingProjectDeploy === void 0 ? void 0 : existingProjectDeploy.id).toBe('5');
17
+ const nonExistingProjectDeploy = await client.getProjectDeployEndpoint().getById('test');
18
+ expect(nonExistingProjectDeploy).toBeNull();
19
+ });
@@ -3,6 +3,6 @@ import { Project } from '../Model/Project/Project';
3
3
  export declare class ProjectEndpoint extends Endpoint {
4
4
  getAll(): Promise<Project[]>;
5
5
  getByTeam(teamId: string): Promise<Project[]>;
6
- getById(projectId: string): Promise<Project>;
6
+ getById(projectId: string): Promise<Project | null>;
7
7
  save(project: Project): Promise<Project>;
8
8
  }
@@ -4,6 +4,7 @@ exports.ProjectEndpoint = void 0;
4
4
  const Endpoint_1 = require("./Endpoint");
5
5
  const Project_1 = require("../Model/Project/Project");
6
6
  const Utils_1 = require("../Utils");
7
+ const HttpClient_1 = require("../Http/HttpClient");
7
8
  class ProjectEndpoint extends Endpoint_1.Endpoint {
8
9
  async getAll() {
9
10
  try {
@@ -35,15 +36,18 @@ class ProjectEndpoint extends Endpoint_1.Endpoint {
35
36
  try {
36
37
  const rawProject = await this.httpClient.request('projects/' + projectId + '');
37
38
  if (Utils_1.Utils.isNullOrUndefined(rawProject)) {
38
- throw new Error('Unable to get project');
39
+ return null;
39
40
  }
40
41
  return Project_1.Project.parse(rawProject);
41
42
  }
42
- catch (e) {
43
+ catch (error) {
44
+ if (error.code === HttpClient_1.HttpClient.HTTP_NOTFOUND) {
45
+ return null;
46
+ }
43
47
  if (this.httpClient.isDebugEnabled()) {
44
- console.error('Failed to load project by id: ' + e);
48
+ console.error('Failed to load project by id: ' + error);
45
49
  }
46
- throw e;
50
+ throw error;
47
51
  }
48
52
  }
49
53
  save(project) {
@@ -2,6 +2,6 @@ import { Endpoint } from './Endpoint';
2
2
  import { ProjectEnvironment } from '../Model/Project/ProjectEnvironment';
3
3
  export declare class ProjectEnvironmentEndpoint extends Endpoint {
4
4
  getByProject(id: string): Promise<ProjectEnvironment[]>;
5
- getById(id: string): Promise<ProjectEnvironment>;
5
+ getById(id: string): Promise<ProjectEnvironment | null>;
6
6
  save(projectEnvironment: ProjectEnvironment): Promise<ProjectEnvironment>;
7
7
  }
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ProjectEnvironmentEndpoint = void 0;
4
4
  const Endpoint_1 = require("./Endpoint");
5
5
  const ProjectEnvironment_1 = require("../Model/Project/ProjectEnvironment");
6
+ const HttpClient_1 = require("../Http/HttpClient");
6
7
  class ProjectEnvironmentEndpoint extends Endpoint_1.Endpoint {
7
8
  async getByProject(id) {
8
9
  try {
@@ -20,10 +21,16 @@ class ProjectEnvironmentEndpoint extends Endpoint_1.Endpoint {
20
21
  async getById(id) {
21
22
  try {
22
23
  const rawProjectEnvironment = await this.httpClient.request('/projectenvironments/' + id + '');
24
+ if (rawProjectEnvironment === null || rawProjectEnvironment === undefined) {
25
+ return null;
26
+ }
23
27
  const projectEnvironment = ProjectEnvironment_1.ProjectEnvironment.parse(rawProjectEnvironment);
24
28
  return projectEnvironment;
25
29
  }
26
30
  catch (error) {
31
+ if (error.code === HttpClient_1.HttpClient.HTTP_NOTFOUND) {
32
+ return null;
33
+ }
27
34
  if (this.httpClient.isDebugEnabled()) {
28
35
  console.error('Failed to load project environment by id', error);
29
36
  }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const Client_1 = require("../Client");
4
+ jest.setTimeout((60) * 1000);
5
+ const apiEndpoint = 'http://localhost:5728/';
6
+ // const apiEndpoint: string = 'https://api2.attlaz.com';
7
+ const clientCredentialClientId = 'zSGdVWE3FAS8kY5C';
8
+ const clientCredentialClientSecret = '6jhYgFPAUm9HmCus';
9
+ test('Test get project environment', async () => {
10
+ expect.assertions(3);
11
+ let client = new Client_1.Client(apiEndpoint, clientCredentialClientId, clientCredentialClientSecret);
12
+ client.getHttpClient().enableDebug();
13
+ await client.authenticate();
14
+ const existingProjectEnvironment = await client.getProjectEnvironmentEndpoint().getById('11');
15
+ expect(existingProjectEnvironment).not.toBeNull();
16
+ expect(existingProjectEnvironment === null || existingProjectEnvironment === void 0 ? void 0 : existingProjectEnvironment.id).toBe('11');
17
+ const nonExistingProjectDeploy = await client.getProjectEnvironmentEndpoint().getById('random');
18
+ expect(nonExistingProjectDeploy).toBeNull();
19
+ });
@@ -3,7 +3,7 @@ import { Task } from '../Model/Task';
3
3
  import { TaskSummary } from '../Model/TaskSummary';
4
4
  export declare class TaskEndpoint extends Endpoint {
5
5
  getTasks(projectId: string): Promise<Task[]>;
6
- getTask(taskId: string): Promise<Task>;
6
+ getTask(taskId: string): Promise<Task | null>;
7
7
  getTaskSummaries(projectId: string, projectEnvironmentId?: string | null): Promise<TaskSummary[]>;
8
8
  getTaskSummary(taskId: string, projectEnvironmentId?: string | null): Promise<TaskSummary>;
9
9
  save(task: Task): Promise<Task>;
@@ -5,6 +5,7 @@ const Endpoint_1 = require("./Endpoint");
5
5
  const Task_1 = require("../Model/Task");
6
6
  const Utils_1 = require("../Utils");
7
7
  const TaskSummary_1 = require("../Model/TaskSummary");
8
+ const HttpClient_1 = require("../Http/HttpClient");
8
9
  class TaskEndpoint extends Endpoint_1.Endpoint {
9
10
  getTasks(projectId) {
10
11
  return new Promise((resolve, reject) => {
@@ -26,15 +27,18 @@ class TaskEndpoint extends Endpoint_1.Endpoint {
26
27
  try {
27
28
  const rawTask = await this.httpClient.request('/tasks/' + taskId);
28
29
  if (Utils_1.Utils.isNullOrUndefined(rawTask)) {
29
- throw new Error('Task not found');
30
+ return null;
30
31
  }
31
32
  return Task_1.Task.parse(rawTask);
32
33
  }
33
- catch (e) {
34
+ catch (error) {
35
+ if (error.code === HttpClient_1.HttpClient.HTTP_NOTFOUND) {
36
+ return null;
37
+ }
34
38
  if (this.httpClient.isDebugEnabled()) {
35
- console.error('Failed to load tasks: ' + e);
39
+ console.error('Failed to load tasks: ' + error);
36
40
  }
37
- throw e;
41
+ throw error;
38
42
  }
39
43
  }
40
44
  getTaskSummaries(projectId, projectEnvironmentId = null) {
package/dist/version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const VERSION = "1.8.23";
1
+ export declare const VERSION = "1.8.25";
package/dist/version.js CHANGED
@@ -1,4 +1,4 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.VERSION = void 0;
4
- exports.VERSION = "1.8.23";
4
+ exports.VERSION = "1.8.25";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "attlaz-client",
3
- "version": "1.8.23",
3
+ "version": "1.8.25",
4
4
  "description": "Javascript Client to access Attlaz API",
5
5
  "types": "./dist/index.d.ts",
6
6
  "main": "./dist/index.js",