attlaz-client 1.5.1 → 1.5.2

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
  }
@@ -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 { 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.2",
4
4
  "description": "Javascript Client to access Attlaz API",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",