attlaz-client 1.5.0 → 1.5.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 (34) hide show
  1. package/dist/Model/Result/DataResult.d.ts +2 -1
  2. package/dist/Model/Result/DataResult.js +6 -0
  3. package/dist/Model/TaskExecutionSummary.d.ts +1 -1
  4. package/dist/Model/TaskExecutionSummary.js +1 -0
  5. package/dist/Model/TaskSummary.d.ts +1 -1
  6. package/dist/Model/TaskSummary.js +4 -1
  7. package/dist/Model/Team/TeamMember.js +3 -0
  8. package/dist/Model/User/UserAuthProvider.d.ts +1 -1
  9. package/dist/Model/User/UserAuthProvider.js +4 -1
  10. package/dist/Model/User.d.ts +1 -1
  11. package/dist/Model/User.js +4 -1
  12. package/dist/Service/ChannelEndpoint.d.ts +1 -1
  13. package/dist/Service/HealthAlertEndpoint.d.ts +1 -1
  14. package/dist/Service/HealthAlertEndpoint.js +3 -4
  15. package/dist/Service/LogEndpoint.d.ts +1 -1
  16. package/dist/Service/LogEndpoint.js +2 -2
  17. package/dist/Service/ProjectDeployEndpoint.d.ts +1 -1
  18. package/dist/Service/ProjectDeployEndpoint.js +1 -1
  19. package/dist/Service/ProjectEndpoint.d.ts +1 -1
  20. package/dist/Service/ProjectEndpoint.js +1 -1
  21. package/dist/Service/ProjectEnvironmentEndpoint.d.ts +1 -1
  22. package/dist/Service/ProjectEnvironmentEndpoint.js +0 -3
  23. package/dist/Service/TaskEndpoint.d.ts +2 -2
  24. package/dist/Service/TaskEndpoint.js +2 -2
  25. package/dist/Service/TaskExecutionEndpoint.d.ts +1 -1
  26. package/dist/Service/TaskExecutionEndpoint.js +1 -1
  27. package/dist/Service/TeamMemberEndpoint.js +3 -1
  28. package/dist/Service/TriggerEndpoint.d.ts +1 -1
  29. package/dist/Service/TriggerEndpoint.js +1 -1
  30. package/dist/Service/WorkerConfigEndpoint.d.ts +1 -1
  31. package/dist/Service/WorkerConfigEndpoint.js +2 -2
  32. package/dist/Service/WorkerEndpoint.d.ts +1 -1
  33. package/dist/Service/WorkerEndpoint.js +1 -1
  34. package/package.json +1 -1
@@ -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
  }
@@ -1,7 +1,7 @@
1
1
  import { TaskExecutionStatus } from "./TaskExecutionStatus";
2
2
  import { TaskExecution } from './TaskExecution';
3
3
  export declare class TaskExecutionSummary extends TaskExecution {
4
- time: Date;
4
+ time: Date | null;
5
5
  duration: number;
6
6
  status: TaskExecutionStatus;
7
7
  static parse(rawTaskExecutionSummary: any): TaskExecutionSummary;
@@ -7,6 +7,7 @@ const Utils_1 = require("../Utils");
7
7
  class TaskExecutionSummary extends TaskExecution_1.TaskExecution {
8
8
  constructor() {
9
9
  super(...arguments);
10
+ this.time = null;
10
11
  this.status = TaskExecutionStatus_1.TaskExecutionStatus.Unknown;
11
12
  }
12
13
  static parse(rawTaskExecutionSummary) {
@@ -2,7 +2,7 @@ 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;
5
+ lastExecution: Date | null;
6
6
  averageExecutionDuration: number;
7
7
  executionCount: number;
8
8
  static parse(rawTask: any): TaskSummary;
@@ -8,11 +8,14 @@ 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;
11
12
  }
12
13
  static parse(rawTask) {
13
14
  let task = Task_1.Task.parse(rawTask);
14
15
  task.status = TaskExecutionStatus_1.TaskExecutionStatus.fromString(rawTask.status);
15
- task.lastExecution = Utils_1.Utils.parseRawDate(rawTask.lastExecution);
16
+ if (rawTask.lastExecution !== null && rawTask.lastExecution !== undefined) {
17
+ task.lastExecution = Utils_1.Utils.parseRawDate(rawTask.lastExecution);
18
+ }
16
19
  task.averageExecutionDuration = rawTask.averageExecutionDuration;
17
20
  task.executionCount = rawTask.executionCount;
18
21
  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
  }
@@ -3,7 +3,7 @@ import { DataResult } from '../Model/Result/DataResult';
3
3
  import { Channel } from '../Model/Messaging/Channel/Channel';
4
4
  import { ChannelHistory } from '../Model/Messaging/ChannelHistory';
5
5
  export declare class ChannelEndpoint extends Endpoint {
6
- getById(channelId: string): Promise<DataResult<Channel | null>>;
6
+ getById(channelId: string): Promise<DataResult<Channel>>;
7
7
  getByTeam(teamId: string): Promise<Channel[]>;
8
8
  getByOwner(): Promise<Channel[]>;
9
9
  getMessages(channelId: string): Promise<DataResult<ChannelHistory[]>>;
@@ -1,5 +1,5 @@
1
1
  import { Endpoint } from './Endpoint';
2
2
  import { HealthAlert } from '../Model/HealthAlert/HealthAlert';
3
3
  export declare class HealthAlertEndpoint extends Endpoint {
4
- getLatestByProjectEnvironment(projectEnvironmentId: string): Promise<HealthAlert[] | null>;
4
+ getLatestByProjectEnvironment(projectEnvironmentId: string): Promise<HealthAlert[]>;
5
5
  }
@@ -3,15 +3,14 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.HealthAlertEndpoint = void 0;
4
4
  const Endpoint_1 = require("./Endpoint");
5
5
  const HealthAlert_1 = require("../Model/HealthAlert/HealthAlert");
6
- const Utils_1 = require("../Utils");
7
6
  class HealthAlertEndpoint extends Endpoint_1.Endpoint {
8
7
  async getLatestByProjectEnvironment(projectEnvironmentId) {
9
8
  try {
10
9
  let url = '/projectenvironments/' + projectEnvironmentId + '/health';
11
10
  const result = await this.request(url);
12
- if (Utils_1.Utils.isNullOrUndefined(result)) {
13
- return null;
14
- }
11
+ // if (Utils.isNullOrUndefined(result)) {
12
+ // return null;
13
+ // }
15
14
  let alerts = [];
16
15
  const resultData = result.getData();
17
16
  if (resultData !== null) {
@@ -13,5 +13,5 @@ export declare class LogEndpoint extends Endpoint {
13
13
  getInformation(logStreamId: LogStreamId): Promise<{
14
14
  logLevels: Map<LogLevel, number>;
15
15
  tags: Map<string, (DataValueValue)[]>;
16
- } | null>;
16
+ }>;
17
17
  }
@@ -95,11 +95,11 @@ class LogEndpoint extends Endpoint_1.Endpoint {
95
95
  let url = '/logstreams/' + Utils_1.Utils.base64encode(logStreamId.id) + '/info';
96
96
  const dataResult = await this.request(url);
97
97
  if (Utils_1.Utils.isNullOrUndefined(dataResult)) {
98
- return null;
98
+ throw new Error('Invalid response');
99
99
  }
100
100
  const data = dataResult.getData();
101
101
  if (data === null) {
102
- return null;
102
+ throw new Error('Invalid response');
103
103
  }
104
104
  const rawData = data;
105
105
  const logLevels = new Map();
@@ -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
  }
@@ -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 | null>;
5
+ getById(id: string): Promise<ProjectEnvironment>;
6
6
  save(projectEnvironment: ProjectEnvironment): Promise<ProjectEnvironment>;
7
7
  }
@@ -23,9 +23,6 @@ class ProjectEnvironmentEndpoint extends Endpoint_1.Endpoint {
23
23
  async getById(id) {
24
24
  try {
25
25
  const rawProjectEnvironment = await this.httpClient.request('/projectenvironments/' + id + '');
26
- if (rawProjectEnvironment === null) {
27
- return null;
28
- }
29
26
  const projectEnvironment = rawProjectEnvironment;
30
27
  return projectEnvironment;
31
28
  }
@@ -3,8 +3,8 @@ 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 | null>;
6
+ getTask(taskId: string): Promise<Task>;
7
7
  getTaskSummaries(projectId: string, projectEnvironmentId?: string | null): Promise<TaskSummary[]>;
8
- getTaskSummary(taskId: string, projectEnvironmentId?: string | null): Promise<TaskSummary | null>;
8
+ getTaskSummary(taskId: string, projectEnvironmentId?: string | null): Promise<TaskSummary>;
9
9
  save(task: Task): Promise<Task>;
10
10
  }
@@ -26,7 +26,7 @@ class TaskEndpoint extends Endpoint_1.Endpoint {
26
26
  try {
27
27
  const rawTask = await this.httpClient.request('/tasks/' + taskId);
28
28
  if (Utils_1.Utils.isNullOrUndefined(rawTask)) {
29
- return null;
29
+ throw new Error('Task not found');
30
30
  }
31
31
  return Task_1.Task.parse(rawTask);
32
32
  }
@@ -65,7 +65,7 @@ class TaskEndpoint extends Endpoint_1.Endpoint {
65
65
  try {
66
66
  const rawTaskSummary = await this.httpClient.request('tasks/' + taskId + '/summaries', parameters);
67
67
  if (Utils_1.Utils.isNullOrUndefined(rawTaskSummary)) {
68
- return null;
68
+ throw new Error('Task not found');
69
69
  }
70
70
  return TaskSummary_1.TaskSummary.parse(rawTaskSummary);
71
71
  }
@@ -6,7 +6,7 @@ import { TaskExecutionStatus } from '../Model/TaskExecutionStatus';
6
6
  export declare class TaskExecutionEndpoint extends Endpoint {
7
7
  getTaskExecutions(taskId: string): Promise<TaskExecution[]>;
8
8
  getTaskExecutionSummaries(taskId: string, from?: Date | null, to?: Date | null, projectEnvironmentId?: string | null): Promise<TaskExecutionSummary[]>;
9
- getTaskExecutionSummary(taskExecutionId: string): Promise<TaskExecutionSummary | null>;
9
+ getTaskExecutionSummary(taskExecutionId: string): Promise<TaskExecutionSummary>;
10
10
  getTaskExecutionHistory(taskExecutionId: string): Promise<TaskExecutionHistory[]>;
11
11
  updateTaskExecution(taskExecutionId: string, status: TaskExecutionStatus, time?: Date | null): Promise<TaskExecution>;
12
12
  }
@@ -62,7 +62,7 @@ class TaskExecutionEndpoint extends Endpoint_1.Endpoint {
62
62
  try {
63
63
  const rawTaskExecution = await this.httpClient.request('/taskexecutions/' + taskExecutionId + '/summaries');
64
64
  if (Utils_1.Utils.isNullOrUndefined(rawTaskExecution)) {
65
- return null;
65
+ throw new Error('Unable to get task execution');
66
66
  }
67
67
  return TaskExecutionSummary_1.TaskExecutionSummary.parse(rawTaskExecution);
68
68
  }
@@ -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) {
@@ -3,7 +3,7 @@ import { Worker } from '../Model/Worker/Worker';
3
3
  import { DataResult } from '../Model/Result/DataResult';
4
4
  import { Platform } from '../Model/Worker/Platform';
5
5
  export declare class WorkerEndpoint extends Endpoint {
6
- getByProjectEnvironment(projectEnvironmentId: string): Promise<Worker | null>;
6
+ getByProjectEnvironment(projectEnvironmentId: string): Promise<Worker>;
7
7
  update(projectEnvironmentId: string): Promise<DataResult<boolean>>;
8
8
  getPlatforms(): Promise<Platform[]>;
9
9
  }
@@ -12,7 +12,7 @@ class WorkerEndpoint extends Endpoint_1.Endpoint {
12
12
  let url = '/projectenvironments/' + projectEnvironmentId + '/workers';
13
13
  const result = await this.httpClient.request(url);
14
14
  if (Utils_1.Utils.isNullOrUndefined(result)) {
15
- return null;
15
+ throw new Error('Unable to find worker');
16
16
  }
17
17
  return Worker_1.Worker.parse(result);
18
18
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "attlaz-client",
3
- "version": "1.5.0",
3
+ "version": "1.5.3",
4
4
  "description": "Javascript Client to access Attlaz API",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",