attlaz-client 1.5.1 → 1.5.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.
@@ -5,7 +5,8 @@ export declare class DataResult<T> {
5
5
  constructor();
6
6
  static parse<T>(raw: any): DataResult<T>;
7
7
  setData(data: T): void;
8
- getData(): T | null;
8
+ getData(): T;
9
+ hasData(): boolean;
9
10
  addError(error: ResultError): void;
10
11
  getErrors(): ResultError[];
11
12
  hasErrors(): boolean;
@@ -22,8 +22,14 @@ class DataResult {
22
22
  this.data = data;
23
23
  }
24
24
  getData() {
25
+ if (this.data === null) {
26
+ throw new Error('Data is empty');
27
+ }
25
28
  return this.data;
26
29
  }
30
+ hasData() {
31
+ return this.data !== null;
32
+ }
27
33
  addError(error) {
28
34
  this.errors.push(error);
29
35
  }
@@ -2,7 +2,7 @@ import { TaskExecutionStatus } from "./TaskExecutionStatus";
2
2
  import { TaskExecution } from './TaskExecution';
3
3
  export declare class TaskExecutionSummary extends TaskExecution {
4
4
  time: Date;
5
- duration: number;
5
+ duration: number | null;
6
6
  status: TaskExecutionStatus;
7
7
  static parse(rawTaskExecutionSummary: any): TaskExecutionSummary;
8
8
  }
@@ -7,13 +7,15 @@ const Utils_1 = require("../Utils");
7
7
  class TaskExecutionSummary extends TaskExecution_1.TaskExecution {
8
8
  constructor() {
9
9
  super(...arguments);
10
+ this.duration = null;
10
11
  this.status = TaskExecutionStatus_1.TaskExecutionStatus.Unknown;
11
12
  }
12
13
  static parse(rawTaskExecutionSummary) {
13
14
  let taskExecutionSummary = TaskExecution_1.TaskExecution.parse(rawTaskExecutionSummary);
14
15
  if (rawTaskExecutionSummary.time !== null && rawTaskExecutionSummary.time !== undefined) {
15
- taskExecutionSummary.time = Utils_1.Utils.parseRawDate(rawTaskExecutionSummary.time);
16
+ throw new Error('Task execution time cannot be empty');
16
17
  }
18
+ taskExecutionSummary.time = Utils_1.Utils.parseRawDate(rawTaskExecutionSummary.time);
17
19
  taskExecutionSummary.duration = rawTaskExecutionSummary.duration;
18
20
  taskExecutionSummary.status = rawTaskExecutionSummary.status;
19
21
  return taskExecutionSummary;
@@ -2,8 +2,8 @@ import { TaskExecutionStatus } from "./TaskExecutionStatus";
2
2
  import { Task } from './Task';
3
3
  export declare class TaskSummary extends Task {
4
4
  status: TaskExecutionStatus;
5
- lastExecution: Date;
6
- averageExecutionDuration: number;
5
+ lastExecution: Date | null;
6
+ averageExecutionDuration: number | null;
7
7
  executionCount: number;
8
8
  static parse(rawTask: any): TaskSummary;
9
9
  }
@@ -8,11 +8,16 @@ class TaskSummary extends Task_1.Task {
8
8
  constructor() {
9
9
  super(...arguments);
10
10
  this.status = TaskExecutionStatus_1.TaskExecutionStatus.Unknown;
11
+ this.lastExecution = null;
12
+ this.averageExecutionDuration = null;
13
+ this.executionCount = 0;
11
14
  }
12
15
  static parse(rawTask) {
13
16
  let task = Task_1.Task.parse(rawTask);
14
17
  task.status = TaskExecutionStatus_1.TaskExecutionStatus.fromString(rawTask.status);
15
- task.lastExecution = Utils_1.Utils.parseRawDate(rawTask.lastExecution);
18
+ if (rawTask.lastExecution !== null && rawTask.lastExecution !== undefined) {
19
+ task.lastExecution = Utils_1.Utils.parseRawDate(rawTask.lastExecution);
20
+ }
16
21
  task.averageExecutionDuration = rawTask.averageExecutionDuration;
17
22
  task.executionCount = rawTask.executionCount;
18
23
  return task;
@@ -2,5 +2,8 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.TeamMember = void 0;
4
4
  class TeamMember {
5
+ constructor() {
6
+ this.last_login = null;
7
+ }
5
8
  }
6
9
  exports.TeamMember = TeamMember;
@@ -6,7 +6,7 @@ export declare class UserAuthProvider implements StateAware {
6
6
  provider: string;
7
7
  providerUserId: string;
8
8
  providerUserEmail: string;
9
- lastUsed: Date;
9
+ lastUsed: Date | null;
10
10
  state: State;
11
11
  static parse(raw: any): UserAuthProvider;
12
12
  }
@@ -5,6 +5,7 @@ const State_1 = require("../State");
5
5
  const Utils_1 = require("../../Utils");
6
6
  class UserAuthProvider {
7
7
  constructor() {
8
+ this.lastUsed = null;
8
9
  this.state = State_1.State.Active;
9
10
  }
10
11
  static parse(raw) {
@@ -14,7 +15,9 @@ class UserAuthProvider {
14
15
  userAuthProvider.provider = raw.provider;
15
16
  userAuthProvider.providerUserId = raw.providerUserId;
16
17
  userAuthProvider.providerUserEmail = raw.providerUserEmail;
17
- userAuthProvider.lastUsed = Utils_1.Utils.parseRawDate(raw.lastUsed);
18
+ if (raw.lastUsed !== null && raw.lastUsed !== undefined) {
19
+ userAuthProvider.lastUsed = Utils_1.Utils.parseRawDate(raw.lastUsed);
20
+ }
18
21
  userAuthProvider.state = State_1.State.fromString(raw.state);
19
22
  return userAuthProvider;
20
23
  }
@@ -14,6 +14,6 @@ export declare class User implements StateAware {
14
14
  time_format: string;
15
15
  picture: string;
16
16
  state: State;
17
- last_active: Date;
17
+ last_active: Date | null;
18
18
  static parse(rawUser: any): User;
19
19
  }
@@ -6,6 +6,7 @@ const State_1 = require("./State");
6
6
  class User {
7
7
  constructor() {
8
8
  this.state = State_1.State.Active;
9
+ this.last_active = null;
9
10
  }
10
11
  static parse(rawUser) {
11
12
  let user = new User();
@@ -21,7 +22,9 @@ class User {
21
22
  user.time_format = rawUser.time_format;
22
23
  user.picture = rawUser.picture;
23
24
  user.state = State_1.State.fromString(rawUser.state);
24
- user.last_active = Utils_1.Utils.parseRawDate(rawUser.last_active);
25
+ if (rawUser.last_active !== null && rawUser.last_active !== undefined) {
26
+ user.last_active = Utils_1.Utils.parseRawDate(rawUser.last_active);
27
+ }
25
28
  return user;
26
29
  }
27
30
  }
@@ -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: number): Promise<ProjectDeploy | null>;
4
+ getById(deployId: number): Promise<ProjectDeploy>;
5
5
  getByProjectEnvironment(projectEnvironmentId: string): Promise<ProjectDeploy[]>;
6
6
  requestDeploy(projectEnvironmentId: string): Promise<any>;
7
7
  }
@@ -9,7 +9,7 @@ class ProjectDeployEndpoint extends Endpoint_1.Endpoint {
9
9
  try {
10
10
  const rawProjectDeploy = await this.httpClient.request('/deploys/' + deployId);
11
11
  if (Utils_1.Utils.isNullOrUndefined(rawProjectDeploy)) {
12
- return null;
12
+ throw new Error('Unable to get deploy');
13
13
  }
14
14
  return ProjectDeploy_1.ProjectDeploy.parse(rawProjectDeploy);
15
15
  }
@@ -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 | null>;
6
+ getById(projectId: string): Promise<Project>;
7
7
  save(project: Project): Promise<Project>;
8
8
  }
@@ -41,7 +41,7 @@ class ProjectEndpoint extends Endpoint_1.Endpoint {
41
41
  try {
42
42
  const rawProject = await this.httpClient.request('projects/' + projectId + '');
43
43
  if (Utils_1.Utils.isNullOrUndefined(rawProject)) {
44
- return null;
44
+ throw new Error('Unable to get project');
45
45
  }
46
46
  return Project_1.Project.parse(rawProject);
47
47
  }
@@ -17,7 +17,9 @@ class TeamMemberEndpoint extends Endpoint_1.Endpoint {
17
17
  member.id = rawMember.id;
18
18
  member.email = rawMember.email;
19
19
  member.invite = Utils_1.Utils.isTrue(rawMember.invite);
20
- member.last_login = Utils_1.Utils.parseRawDate(rawMember.last_login);
20
+ if (rawMember.last_login !== null && rawMember.last_login !== undefined) {
21
+ member.last_login = Utils_1.Utils.parseRawDate(rawMember.last_login);
22
+ }
21
23
  member.name = rawMember.name;
22
24
  member.role = TeamMemberRole_1.TeamMemberRole.fromString(rawMember.role);
23
25
  if (member.invite) {
@@ -2,6 +2,6 @@ import { Endpoint } from './Endpoint';
2
2
  import { Trigger } from '../Model/Trigger/Trigger';
3
3
  export declare class TriggerEndpoint extends Endpoint {
4
4
  getByTask(taskId: string, projectEnvironmentId?: string | null): Promise<Trigger[]>;
5
- getById(id: string): Promise<Trigger | null>;
5
+ getById(id: string): Promise<Trigger>;
6
6
  save(trigger: Trigger): Promise<Trigger>;
7
7
  }
@@ -29,7 +29,7 @@ class TriggerEndpoint extends Endpoint_1.Endpoint {
29
29
  try {
30
30
  const result = await this.httpClient.request('/triggers/' + id);
31
31
  if (Utils_1.Utils.isNullOrUndefined(result)) {
32
- return null;
32
+ throw new Error('Unable to get trigger');
33
33
  }
34
34
  return Trigger_1.Trigger.parse(result);
35
35
  }
@@ -1,6 +1,6 @@
1
1
  import { Endpoint } from './Endpoint';
2
2
  import { WorkerConfig } from '../Model/Worker/WorkerConfig';
3
3
  export declare class WorkerConfigEndpoint extends Endpoint {
4
- getByProjectEnvironment(projectEnvironmentId: string): Promise<WorkerConfig[] | null>;
4
+ getByProjectEnvironment(projectEnvironmentId: string): Promise<WorkerConfig[]>;
5
5
  save(workerConfig: WorkerConfig): Promise<WorkerConfig>;
6
6
  }
@@ -10,11 +10,11 @@ class WorkerConfigEndpoint extends Endpoint_1.Endpoint {
10
10
  let url = '/projectenvironments/' + projectEnvironmentId + '/workerconfiguration';
11
11
  const result = await this.request(url);
12
12
  if (Utils_1.Utils.isNullOrUndefined(result)) {
13
- return null;
13
+ throw new Error('Unable to get project environment');
14
14
  }
15
15
  const resultData = result.getData();
16
16
  if (resultData === null) {
17
- return null;
17
+ throw new Error('Unable to get project environment');
18
18
  }
19
19
  let workerConfigValues = [];
20
20
  for (let rawConfig of resultData) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "attlaz-client",
3
- "version": "1.5.1",
3
+ "version": "1.5.4",
4
4
  "description": "Javascript Client to access Attlaz API",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",