attlaz-client 1.8.6 → 1.8.9

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.
@@ -4,11 +4,14 @@ export declare class Project implements StateAware {
4
4
  id: string;
5
5
  key: string;
6
6
  name: string;
7
- team: string;
7
+ teamId: string;
8
8
  default: boolean;
9
9
  defaultEnvironmentId: string;
10
+ /** @deprecated **/
10
11
  source_account: number;
12
+ /** @deprecated **/
11
13
  source_repository: string;
14
+ /** @deprecated **/
12
15
  language: number;
13
16
  state: State;
14
17
  constructor(id: string, key: string, name: string);
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Project = void 0;
4
4
  const State_1 = require("../State");
5
+ const Utils_1 = require("../../Utils");
5
6
  class Project {
6
7
  constructor(id, key, name) {
7
8
  this.default = false;
@@ -12,9 +13,14 @@ class Project {
12
13
  }
13
14
  static parse(rawProject) {
14
15
  let project = new Project(rawProject.id, rawProject.key, rawProject.name);
15
- project.team = rawProject.team;
16
+ if (rawProject.team !== undefined) {
17
+ project.teamId = rawProject.team;
18
+ }
19
+ else {
20
+ project.teamId = rawProject.teamId;
21
+ }
16
22
  if (rawProject.default !== null && rawProject.default !== undefined) {
17
- project.default = (rawProject.default.toString() === '1');
23
+ project.default = Utils_1.Utils.isTrue(rawProject.default);
18
24
  }
19
25
  project.defaultEnvironmentId = rawProject.defaultEnvironmentId;
20
26
  project.source_account = rawProject.source_account;
@@ -5,8 +5,9 @@ export declare class ProjectEnvironment implements StateAware {
5
5
  key: string;
6
6
  projectId: string;
7
7
  name: string;
8
+ /** @deprecated **/
8
9
  sourceBranch: string;
9
- parent: string | null;
10
+ parentId: string | null;
10
11
  isLocal: boolean;
11
12
  state: State;
12
13
  static parse(rawProjectEnvironment: any): ProjectEnvironment;
@@ -5,7 +5,7 @@ const State_1 = require("../State");
5
5
  const Utils_1 = require("../../Utils");
6
6
  class ProjectEnvironment {
7
7
  constructor() {
8
- this.parent = null;
8
+ this.parentId = null;
9
9
  this.isLocal = false;
10
10
  this.state = State_1.State.Active;
11
11
  }
@@ -13,10 +13,20 @@ class ProjectEnvironment {
13
13
  const projectEnvironment = new ProjectEnvironment();
14
14
  projectEnvironment.id = rawProjectEnvironment.id;
15
15
  projectEnvironment.key = rawProjectEnvironment.key;
16
- projectEnvironment.projectId = rawProjectEnvironment.project;
16
+ if (rawProjectEnvironment.project !== undefined) {
17
+ projectEnvironment.projectId = rawProjectEnvironment.project;
18
+ }
19
+ else {
20
+ projectEnvironment.projectId = rawProjectEnvironment.projectId;
21
+ }
17
22
  projectEnvironment.name = rawProjectEnvironment.name;
18
23
  projectEnvironment.sourceBranch = rawProjectEnvironment.source_branch;
19
- projectEnvironment.parent = rawProjectEnvironment.parent;
24
+ if (rawProjectEnvironment.parent !== undefined) {
25
+ projectEnvironment.parentId = rawProjectEnvironment.parent;
26
+ }
27
+ else {
28
+ projectEnvironment.parentId = rawProjectEnvironment.parentId;
29
+ }
20
30
  projectEnvironment.isLocal = Utils_1.Utils.isTrue(rawProjectEnvironment.is_local);
21
31
  projectEnvironment.state = State_1.State.fromString(rawProjectEnvironment.state);
22
32
  return projectEnvironment;
@@ -11,14 +11,17 @@ class DataResult {
11
11
  if (raw === null || raw === undefined) {
12
12
  throw new Error('Unable to parse DataResult: result: empty');
13
13
  }
14
- if (!raw.hasOwnProperty('data') || raw.data === undefined) {
15
- throw new Error('Unable to parse DataResult: data is not defined');
16
- }
17
- else {
18
- result.setData(raw.data);
19
- }
20
- if (!raw.hasOwnProperty('errors') || raw.errors === undefined || raw.errors === null) {
21
- console.error('Unable to parse DataResult (ignore for now, not setting any errors): errors is not defined');
14
+ if (raw.hasOwnProperty('errors')) {
15
+ if (raw.errors === undefined || raw.errors === null) {
16
+ console.error('Unable to parse DataResult: errors defined but invalid value', raw);
17
+ }
18
+ else {
19
+ const errors = raw.errors;
20
+ for (const error of errors) {
21
+ result.addError(error);
22
+ }
23
+ }
24
+ return result;
22
25
  }
23
26
  else {
24
27
  const errors = raw.errors;
@@ -26,6 +29,12 @@ class DataResult {
26
29
  result.addError(error);
27
30
  }
28
31
  }
32
+ if (!raw.hasOwnProperty('data') || raw.data === undefined) {
33
+ throw new Error('Unable to parse DataResult: data is not defined');
34
+ }
35
+ else {
36
+ result.setData(raw.data);
37
+ }
29
38
  return result;
30
39
  }
31
40
  setData(data) {
@@ -5,8 +5,8 @@ export declare class Task implements StateAware {
5
5
  key: string;
6
6
  name: string;
7
7
  description: string;
8
- project: string;
9
- direct: boolean;
8
+ projectId: string;
9
+ isDirect: boolean;
10
10
  state: State;
11
11
  /** The maximum number of tasks to run at any time (0 = no limit) **/
12
12
  parallelLimit: number;
@@ -5,7 +5,7 @@ const State_1 = require("./State");
5
5
  const Utils_1 = require("../Utils");
6
6
  class Task {
7
7
  constructor() {
8
- this.direct = false;
8
+ this.isDirect = false;
9
9
  this.state = State_1.State.Active;
10
10
  /** The maximum number of tasks to run at any time (0 = no limit) **/
11
11
  this.parallelLimit = 0;
@@ -14,10 +14,20 @@ class Task {
14
14
  const task = new Task();
15
15
  task.id = rawTask.id;
16
16
  task.key = rawTask.key;
17
- task.project = rawTask.project;
17
+ if (rawTask.project !== undefined) {
18
+ task.projectId = rawTask.project;
19
+ }
20
+ else {
21
+ task.projectId = rawTask.projectId;
22
+ }
18
23
  task.name = rawTask.name;
19
24
  task.description = rawTask.description;
20
- task.direct = rawTask.direct;
25
+ if (rawTask.direct !== undefined) {
26
+ task.isDirect = Utils_1.Utils.isTrue(rawTask.direct);
27
+ }
28
+ else {
29
+ task.isDirect = rawTask.isDirect;
30
+ }
21
31
  task.state = State_1.State.fromString(rawTask.state);
22
32
  task.parallelLimit = 0;
23
33
  if (rawTask.parallelLimit !== null && rawTask.parallelLimit !== undefined) {
@@ -1,12 +1,12 @@
1
1
  import { LogLevel } from './Log/LogLevel';
2
2
  export declare class TaskExecution {
3
3
  id: string;
4
- code: string;
5
- name: string;
6
4
  taskId: string;
5
+ name: string;
6
+ parentId: string | null;
7
7
  arguments: any;
8
- projectEnvironment: string;
9
- trigger: string;
8
+ projectEnvironmentId: string;
9
+ triggerId: string;
10
10
  deployId: number;
11
11
  logLevelCount: Map<LogLevel, number>;
12
12
  logsPurged: boolean;
@@ -3,22 +3,33 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.TaskExecution = void 0;
4
4
  class TaskExecution {
5
5
  constructor() {
6
+ this.parentId = null;
6
7
  this.logsPurged = false;
7
8
  }
8
9
  static parse(rawTaskExecution) {
9
10
  let taskExecution = new TaskExecution();
10
11
  taskExecution.id = rawTaskExecution.id;
11
- taskExecution.code = rawTaskExecution.code;
12
+ // taskExecution.code = rawTaskExecution.code;
12
13
  taskExecution.name = rawTaskExecution.name;
13
- if (rawTaskExecution.task === undefined) {
14
+ if (rawTaskExecution.task !== undefined) {
14
15
  taskExecution.taskId = rawTaskExecution.task;
15
16
  }
16
17
  else {
17
18
  taskExecution.taskId = rawTaskExecution.taskId;
18
19
  }
19
20
  taskExecution.arguments = rawTaskExecution.arguments;
20
- taskExecution.projectEnvironment = rawTaskExecution.projectEnvironment;
21
- taskExecution.trigger = rawTaskExecution.trigger;
21
+ if (rawTaskExecution.projectEnvironment !== undefined) {
22
+ taskExecution.projectEnvironmentId = rawTaskExecution.projectEnvironment;
23
+ }
24
+ else {
25
+ taskExecution.projectEnvironmentId = rawTaskExecution.projectEnvironmentId;
26
+ }
27
+ if (rawTaskExecution.trigger !== undefined) {
28
+ taskExecution.triggerId = rawTaskExecution.trigger;
29
+ }
30
+ else {
31
+ taskExecution.triggerId = rawTaskExecution.triggerId;
32
+ }
22
33
  taskExecution.deployId = rawTaskExecution.deployId;
23
34
  taskExecution.logLevelCount = rawTaskExecution.logLevelCount;
24
35
  taskExecution.logsPurged = rawTaskExecution.logsPurged;
@@ -4,4 +4,5 @@ export declare class Team implements StateAware {
4
4
  id: string;
5
5
  name: string;
6
6
  state: State;
7
+ static parse(rawTeam: any): Team;
7
8
  }
@@ -1,6 +1,14 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Team = void 0;
4
+ const State_1 = require("../State");
4
5
  class Team {
6
+ static parse(rawTeam) {
7
+ const team = new Team();
8
+ team.id = rawTeam.id;
9
+ team.name = rawTeam.name;
10
+ team.state = State_1.State.fromString(rawTeam.state);
11
+ return team;
12
+ }
5
13
  }
6
14
  exports.Team = Team;
@@ -5,37 +5,31 @@ const Endpoint_1 = require("./Endpoint");
5
5
  const Project_1 = require("../Model/Project/Project");
6
6
  const Utils_1 = require("../Utils");
7
7
  class ProjectEndpoint extends Endpoint_1.Endpoint {
8
- getAll() {
9
- return new Promise((resolve, reject) => {
10
- this.httpClient.request('projects').then((rawProjects) => {
11
- let projects = [];
12
- for (let rawProject of rawProjects) {
13
- projects.push(Project_1.Project.parse(rawProject));
14
- }
15
- resolve(projects);
16
- }).catch((reason) => {
17
- if (this.httpClient.isDebugEnabled()) {
18
- console.error('Failed to load projects: ' + reason);
19
- }
20
- reject(reason);
21
- });
22
- });
8
+ async getAll() {
9
+ try {
10
+ const result = await this.request('/projects');
11
+ result.setData(this.parseCollection(result, Project_1.Project.parse));
12
+ return result.getData();
13
+ }
14
+ catch (e) {
15
+ if (this.httpClient.isDebugEnabled()) {
16
+ console.error('Failed to load projects: ' + e);
17
+ }
18
+ throw e;
19
+ }
23
20
  }
24
- getByTeam(teamId) {
25
- return new Promise((resolve, reject) => {
26
- this.httpClient.request('teams/' + teamId + '/projects').then((rawProjects) => {
27
- let projects = [];
28
- for (let rawProject of rawProjects) {
29
- projects.push(Project_1.Project.parse(rawProject));
30
- }
31
- resolve(projects);
32
- }).catch((reason) => {
33
- if (this.httpClient.isDebugEnabled()) {
34
- console.error('Failed to load projects: ' + reason);
35
- }
36
- reject(reason);
37
- });
38
- });
21
+ async getByTeam(teamId) {
22
+ try {
23
+ const result = await this.request('teams/' + teamId + '/projects');
24
+ result.setData(this.parseCollection(result, Project_1.Project.parse));
25
+ return result.getData();
26
+ }
27
+ catch (e) {
28
+ if (this.httpClient.isDebugEnabled()) {
29
+ console.error('Failed to load projects: ' + e);
30
+ }
31
+ throw e;
32
+ }
39
33
  }
40
34
  async getById(projectId) {
41
35
  try {
@@ -2,16 +2,13 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ProjectEnvironmentEndpoint = void 0;
4
4
  const Endpoint_1 = require("./Endpoint");
5
+ const ProjectEnvironment_1 = require("../Model/Project/ProjectEnvironment");
5
6
  class ProjectEnvironmentEndpoint extends Endpoint_1.Endpoint {
6
7
  async getByProject(id) {
7
8
  try {
8
- const rawProjectEnvironments = await this.httpClient.request('/projects/' + id + '/environments');
9
- let projectEnvironment = [];
10
- for (let rawProjectEnvironment of rawProjectEnvironments) {
11
- //TODO: add parsing
12
- projectEnvironment.push(rawProjectEnvironment);
13
- }
14
- return projectEnvironment;
9
+ const result = await this.request('/projects/' + id + '/environments');
10
+ result.setData(this.parseCollection(result, ProjectEnvironment_1.ProjectEnvironment.parse));
11
+ return result.getData();
15
12
  }
16
13
  catch (error) {
17
14
  if (this.httpClient.isDebugEnabled()) {
@@ -23,7 +20,7 @@ class ProjectEnvironmentEndpoint extends Endpoint_1.Endpoint {
23
20
  async getById(id) {
24
21
  try {
25
22
  const rawProjectEnvironment = await this.httpClient.request('/projectenvironments/' + id + '');
26
- const projectEnvironment = rawProjectEnvironment;
23
+ const projectEnvironment = ProjectEnvironment_1.ProjectEnvironment.parse(rawProjectEnvironment);
27
24
  return projectEnvironment;
28
25
  }
29
26
  catch (error) {
@@ -37,7 +34,7 @@ class ProjectEnvironmentEndpoint extends Endpoint_1.Endpoint {
37
34
  try {
38
35
  const rawProjectEnvironment = await this.httpClient.request('projectenvironments/', projectEnvironment, 'POST');
39
36
  // TODO: parse result
40
- const savedProjectEnvironment = rawProjectEnvironment;
37
+ const savedProjectEnvironment = ProjectEnvironment_1.ProjectEnvironment.parse(rawProjectEnvironment);
41
38
  return savedProjectEnvironment;
42
39
  }
43
40
  catch (error) {
@@ -78,7 +78,7 @@ class TaskEndpoint extends Endpoint_1.Endpoint {
78
78
  }
79
79
  save(task) {
80
80
  return new Promise((resolve, reject) => {
81
- let url = '/projects/' + task.project + '/tasks';
81
+ let url = '/projects/' + task.projectId + '/tasks';
82
82
  this.httpClient.request(url, task, 'POST').then((result) => {
83
83
  resolve(Task_1.Task.parse(result));
84
84
  }).catch((reason) => {
@@ -3,20 +3,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.TeamsEndpoint = void 0;
4
4
  const Endpoint_1 = require("./Endpoint");
5
5
  const Team_1 = require("../Model/Team/Team");
6
- const State_1 = require("../Model/State");
7
6
  class TeamsEndpoint extends Endpoint_1.Endpoint {
8
7
  async getAll() {
9
8
  try {
10
- const rawTeams = await this.httpClient.request('/teams');
11
- let teams = [];
12
- for (let rawTeam of rawTeams) {
13
- let team = new Team_1.Team();
14
- team.id = rawTeam.id;
15
- team.name = rawTeam.name;
16
- team.state = State_1.State.fromString(rawTeam.state);
17
- teams.push(team);
18
- }
19
- return teams;
9
+ const result = await this.request('/teams');
10
+ result.setData(this.parseCollection(result, Team_1.Team.parse));
11
+ return result.getData();
20
12
  }
21
13
  catch (e) {
22
14
  if (this.httpClient.isDebugEnabled()) {
package/dist/version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const VERSION = "1.8.6";
1
+ export declare const VERSION = "1.8.9";
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.6";
4
+ exports.VERSION = "1.8.9";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "attlaz-client",
3
- "version": "1.8.6",
3
+ "version": "1.8.9",
4
4
  "description": "Javascript Client to access Attlaz API",
5
5
  "types": "./dist/index.d.ts",
6
6
  "main": "./dist/index.js",